mirror of https://github.com/itflow-org/itflow
Fixed a few table names in Stripe Migration, Removed legacy stripe and AI settings
This commit is contained in:
parent
1f99e592b7
commit
fd73f132bc
677
REMOVEajax.php
677
REMOVEajax.php
|
|
@ -1,677 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* ajax.php
|
||||
* Similar to post.php, but for requests using Asynchronous JavaScript
|
||||
* Always returns data in JSON format, unless otherwise specified
|
||||
*/
|
||||
|
||||
require_once "config.php";
|
||||
require_once "functions.php";
|
||||
require_once "includes/check_login.php";
|
||||
require_once "plugins/totp/totp.php";
|
||||
|
||||
/*
|
||||
* Fetches SSL certificates from remote hosts & returns the relevant info (issuer, expiry, public key)
|
||||
*/
|
||||
if (isset($_GET['certificate_fetch_parse_json_details'])) {
|
||||
enforceUserPermission('module_support');
|
||||
|
||||
// PHP doesn't appreciate attempting SSL sockets to non-existent domains
|
||||
if (empty($_GET['domain'])) {
|
||||
exit();
|
||||
}
|
||||
|
||||
$name = $_GET['domain'];
|
||||
|
||||
// Get SSL cert for domain (if exists)
|
||||
$certificate = getSSL($name);
|
||||
|
||||
if ($certificate['success'] == "TRUE") {
|
||||
$response['success'] = "TRUE";
|
||||
$response['expire'] = $certificate['expire'];
|
||||
$response['issued_by'] = $certificate['issued_by'];
|
||||
$response['public_key'] = $certificate['public_key'];
|
||||
} else {
|
||||
$response['success'] = "FALSE";
|
||||
}
|
||||
|
||||
echo json_encode($response);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Looks up info on the ticket number provided, used to populate the ticket merge modal
|
||||
*/
|
||||
if (isset($_GET['merge_ticket_get_json_details'])) {
|
||||
enforceUserPermission('module_support');
|
||||
|
||||
$merge_into_ticket_number = intval($_GET['merge_into_ticket_number']);
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT ticket_id, ticket_number, ticket_prefix, ticket_subject, ticket_priority, ticket_status, ticket_status_name, client_name, contact_name FROM tickets
|
||||
LEFT JOIN clients ON ticket_client_id = client_id
|
||||
LEFT JOIN contacts ON ticket_contact_id = contact_id
|
||||
LEFT JOIN ticket_statuses ON ticket_status = ticket_status_id
|
||||
WHERE ticket_number = $merge_into_ticket_number");
|
||||
|
||||
if (mysqli_num_rows($sql) == 0) {
|
||||
//Do nothing.
|
||||
echo "No ticket found!";
|
||||
} else {
|
||||
//Return ticket, client and contact details for the given ticket number
|
||||
$response = mysqli_fetch_array($sql);
|
||||
|
||||
echo json_encode($response);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_POST['client_set_notes'])) {
|
||||
enforceUserPermission('module_client', 2);
|
||||
|
||||
$client_id = intval($_POST['client_id']);
|
||||
$notes = sanitizeInput($_POST['notes']);
|
||||
|
||||
// Update notes
|
||||
mysqli_query($mysqli, "UPDATE clients SET client_notes = '$notes' WHERE client_id = $client_id");
|
||||
|
||||
// Logging
|
||||
logAction("Client", "Edit", "$session_name edited client notes", $client_id);
|
||||
|
||||
}
|
||||
|
||||
if (isset($_POST['contact_set_notes'])) {
|
||||
enforceUserPermission('module_client', 2);
|
||||
|
||||
$contact_id = intval($_POST['contact_id']);
|
||||
$notes = sanitizeInput($_POST['notes']);
|
||||
|
||||
// Get Contact Details and Client ID for Logging
|
||||
$sql = mysqli_query($mysqli,"SELECT contact_name, contact_client_id
|
||||
FROM contacts WHERE contact_id = $contact_id"
|
||||
);
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$contact_name = sanitizeInput($row['contact_name']);
|
||||
$client_id = intval($row['contact_client_id']);
|
||||
|
||||
// Update notes
|
||||
mysqli_query($mysqli, "UPDATE contacts SET contact_notes = '$notes' WHERE contact_id = $contact_id");
|
||||
|
||||
// Logging
|
||||
logAction("Contact", "Edit", "$session_name edited contact notes for $contact_name", $client_id, $contact_id);
|
||||
|
||||
}
|
||||
|
||||
if (isset($_POST['asset_set_notes'])) {
|
||||
enforceUserPermission('module_support', 2);
|
||||
|
||||
$asset_id = intval($_POST['asset_id']);
|
||||
$notes = sanitizeInput($_POST['notes']);
|
||||
|
||||
// Get Asset Details and Client ID for Logging
|
||||
$sql = mysqli_query($mysqli,"SELECT asset_name, asset_client_id
|
||||
FROM assets WHERE asset_id = $asset_id"
|
||||
);
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$asset_name = sanitizeInput($row['asset_name']);
|
||||
$client_id = intval($row['asset_client_id']);
|
||||
|
||||
// Update notes
|
||||
mysqli_query($mysqli, "UPDATE assets SET asset_notes = '$notes' WHERE asset_id = $asset_id");
|
||||
|
||||
// Logging
|
||||
logAction("Asset", "Edit", "$session_name edited asset notes for $asset_name", $client_id, $asset_id);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Ticketing Collision Detection/Avoidance
|
||||
* Called upon loading a ticket, and every 2 mins thereafter
|
||||
* Is used in conjunction with ticket_query_views to show who is currently viewing a ticket
|
||||
*/
|
||||
if (isset($_GET['ticket_add_view'])) {
|
||||
$ticket_id = intval($_GET['ticket_id']);
|
||||
|
||||
mysqli_query($mysqli, "INSERT INTO ticket_views SET view_ticket_id = $ticket_id, view_user_id = $session_user_id, view_timestamp = NOW()");
|
||||
}
|
||||
|
||||
/*
|
||||
* Ticketing Collision Detection/Avoidance
|
||||
* Returns formatted text of the agents currently viewing a ticket
|
||||
* Called upon loading a ticket, and every 2 mins thereafter
|
||||
*/
|
||||
if (isset($_GET['ticket_query_views'])) {
|
||||
$ticket_id = intval($_GET['ticket_id']);
|
||||
|
||||
$query = mysqli_query($mysqli, "SELECT user_name FROM ticket_views LEFT JOIN users ON view_user_id = user_id WHERE view_ticket_id = $ticket_id AND view_user_id != $session_user_id AND view_timestamp > DATE_SUB(NOW(), INTERVAL 2 MINUTE)");
|
||||
while ($row = mysqli_fetch_array($query)) {
|
||||
$users[] = $row['user_name'];
|
||||
}
|
||||
|
||||
if (!empty($users)) {
|
||||
$users = array_unique($users);
|
||||
if (count($users) > 1) {
|
||||
// Multiple viewers
|
||||
$response['message'] = "<i class='fas fa-fw fa-eye mr-2'></i>" . nullable_htmlentities(implode(", ", $users) . " are viewing this ticket.");
|
||||
} else {
|
||||
// Single viewer
|
||||
$response['message'] = "<i class='fas fa-fw fa-eye mr-2'></i>" . nullable_htmlentities(implode("", $users) . " is viewing this ticket.");
|
||||
}
|
||||
} else {
|
||||
// No viewers
|
||||
$response['message'] = "";
|
||||
}
|
||||
|
||||
echo json_encode($response);
|
||||
}
|
||||
|
||||
/*
|
||||
* Generates public/guest links for sharing credentials/docs
|
||||
*/
|
||||
if (isset($_GET['share_generate_link'])) {
|
||||
enforceUserPermission('module_support', 2);
|
||||
|
||||
$item_encrypted_username = ''; // Default empty
|
||||
$item_encrypted_credential = ''; // Default empty
|
||||
|
||||
$client_id = intval($_GET['client_id']);
|
||||
$item_type = sanitizeInput($_GET['type']);
|
||||
$item_id = intval($_GET['id']);
|
||||
$item_email = sanitizeInput($_GET['contact_email']);
|
||||
$item_note = sanitizeInput($_GET['note']);
|
||||
$item_view_limit = intval($_GET['views']);
|
||||
$item_view_limit_wording = "";
|
||||
if ($item_view_limit == 1) {
|
||||
$item_view_limit_wording = " and may only be viewed <strong>once</strong>, before the link is destroyed.";
|
||||
}
|
||||
$item_expires = sanitizeInput($_GET['expires']);
|
||||
$item_expires_friendly = "never"; // default never
|
||||
if ($item_expires == "1 HOUR") {
|
||||
$item_expires_friendly = "1 hour";
|
||||
} elseif ($item_expires == "24 HOUR") {
|
||||
$item_expires_friendly = "1 day";
|
||||
} elseif ($item_expires == "168 HOUR") {
|
||||
$item_expires_friendly = "1 week";
|
||||
} elseif ($item_expires == "730 HOUR") {
|
||||
$item_expires_friendly = "1 month";
|
||||
}
|
||||
|
||||
$item_key = randomString(156);
|
||||
|
||||
if ($item_type == "Document") {
|
||||
$row = mysqli_fetch_array(mysqli_query($mysqli, "SELECT document_name FROM documents WHERE document_id = $item_id AND document_client_id = $client_id LIMIT 1"));
|
||||
$item_name = sanitizeInput($row['document_name']);
|
||||
}
|
||||
|
||||
if ($item_type == "File") {
|
||||
$row = mysqli_fetch_array(mysqli_query($mysqli, "SELECT file_name FROM files WHERE file_id = $item_id AND file_client_id = $client_id LIMIT 1"));
|
||||
$item_name = sanitizeInput($row['file_name']);
|
||||
}
|
||||
|
||||
if ($item_type == "Credential") {
|
||||
$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");
|
||||
$row = mysqli_fetch_array($credential);
|
||||
|
||||
$item_name = sanitizeInput($row['credential_name']);
|
||||
|
||||
// Decrypt & re-encrypt username/password for sharing
|
||||
$credential_encryption_key = randomString();
|
||||
|
||||
$credential_username_cleartext = decryptCredentialEntry($row['credential_username']);
|
||||
$iv = randomString();
|
||||
$username_ciphertext = openssl_encrypt($credential_username_cleartext, 'aes-128-cbc', $credential_encryption_key, 0, $iv);
|
||||
$item_encrypted_username = $iv . $username_ciphertext;
|
||||
|
||||
$credential_password_cleartext = decryptCredentialEntry($row['credential_password']);
|
||||
$iv = randomString();
|
||||
$password_ciphertext = openssl_encrypt($credential_password_cleartext, 'aes-128-cbc', $credential_encryption_key, 0, $iv);
|
||||
$item_encrypted_credential = $iv . $password_ciphertext;
|
||||
}
|
||||
|
||||
// Insert entry into DB
|
||||
$sql = mysqli_query($mysqli, "INSERT INTO shared_items SET item_active = 1, item_key = '$item_key', item_type = '$item_type', item_related_id = $item_id, item_encrypted_username = '$item_encrypted_username', item_encrypted_credential = '$item_encrypted_credential', item_note = '$item_note', item_recipient = '$item_email', item_views = 0, item_view_limit = $item_view_limit, item_expire_at = NOW() + INTERVAL + $item_expires, item_client_id = $client_id");
|
||||
$share_id = $mysqli->insert_id;
|
||||
|
||||
// Return URL
|
||||
if ($item_type == "Credential") {
|
||||
$url = "https://$config_base_url/guest/guest_view_item.php?id=$share_id&key=$item_key&ek=$credential_encryption_key";
|
||||
}
|
||||
else {
|
||||
$url = "https://$config_base_url/guest/guest_view_item.php?id=$share_id&key=$item_key";
|
||||
}
|
||||
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM companies WHERE company_id = 1");
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$company_name = sanitizeInput($row['company_name']);
|
||||
$company_phone = sanitizeInput(formatPhoneNumber($row['company_phone'], $row['company_phone_country_code']));
|
||||
|
||||
// Sanitize Config vars from load_global_settings.php
|
||||
$config_ticket_from_name = sanitizeInput($config_ticket_from_name);
|
||||
$config_ticket_from_email = sanitizeInput($config_ticket_from_email);
|
||||
$config_mail_from_name = sanitizeInput($config_mail_from_name);
|
||||
$config_mail_from_email = sanitizeInput($config_mail_from_email);
|
||||
|
||||
// Send user e-mail, if specified
|
||||
if(!empty($config_smtp_host) && filter_var($item_email, FILTER_VALIDATE_EMAIL)){
|
||||
|
||||
$subject = "Time sensitive - $company_name secure link enclosed";
|
||||
if ($item_expires_friendly == "never") {
|
||||
$subject = "$company_name secure link enclosed";
|
||||
}
|
||||
$body = "Hello,<br><br>$session_name from $company_name sent you a time sensitive secure link regarding \"$item_name\".<br><br>The link will expire in <strong>$item_expires_friendly</strong>$item_view_limit_wording.<br><br><strong><a href=\'$url\'>Click here to access your secure content</a></strong><br><br>--<br>$company_name - Support<br>$config_ticket_from_email<br>$company_phone";
|
||||
|
||||
// Add the intended recipient disclosure
|
||||
$body .= "<br><br><em>This email and any attachments are confidential and intended for the specified recipient(s) only. If you are not the intended recipient, please notify the sender and delete this email. Unauthorized use, disclosure, or distribution is prohibited.</em>";
|
||||
|
||||
$data = [
|
||||
[
|
||||
'from' => $config_mail_from_email,
|
||||
'from_name' => $config_mail_from_name,
|
||||
'recipient' => $item_email,
|
||||
'recipient_name' => $item_email,
|
||||
'subject' => $subject,
|
||||
'body' => $body
|
||||
]
|
||||
];
|
||||
|
||||
addToMailQueue($data);
|
||||
|
||||
}
|
||||
|
||||
echo json_encode($url);
|
||||
|
||||
// Logging
|
||||
logAction("Share", "Create", "$session_name created shared link for $item_type - $item_name", $client_id, $item_id);
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns sorted list of active clients
|
||||
*/
|
||||
if (isset($_GET['get_active_clients'])) {
|
||||
enforceUserPermission('module_client');
|
||||
|
||||
$client_sql = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT client_id, client_name FROM clients
|
||||
WHERE client_archived_at IS NULL
|
||||
$access_permission_query
|
||||
ORDER BY client_accessed_at DESC"
|
||||
);
|
||||
|
||||
while ($row = mysqli_fetch_array($client_sql)) {
|
||||
$response['clients'][] = $row;
|
||||
}
|
||||
|
||||
echo json_encode($response);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns ordered list of active contacts for a specified client
|
||||
*/
|
||||
if (isset($_GET['get_client_contacts'])) {
|
||||
enforceUserPermission('module_client');
|
||||
|
||||
$client_id = intval($_GET['client_id']);
|
||||
|
||||
$contact_sql = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT contact_id, contact_name, contact_primary, contact_important, contact_technical FROM contacts
|
||||
LEFT JOIN clients on contact_client_id = client_id
|
||||
WHERE contacts.contact_archived_at IS NULL AND contact_client_id = $client_id
|
||||
$access_permission_query
|
||||
ORDER BY contact_primary DESC, contact_technical DESC, contact_important DESC, contact_name"
|
||||
);
|
||||
|
||||
while ($row = mysqli_fetch_array($contact_sql)) {
|
||||
$response['contacts'][] = $row;
|
||||
}
|
||||
|
||||
echo json_encode($response);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns ordered list of active assets for a specified client
|
||||
*/
|
||||
if (isset($_GET['get_client_assets'])) {
|
||||
enforceUserPermission('module_client');
|
||||
|
||||
$client_id = intval($_GET['client_id']);
|
||||
|
||||
$asset_sql = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT asset_id, asset_name, contact_name FROM assets
|
||||
LEFT JOIN clients on asset_client_id = client_id
|
||||
LEFT JOIN contacts ON contact_id = asset_contact_id
|
||||
WHERE assets.asset_archived_at IS NULL AND asset_client_id = $client_id
|
||||
$access_permission_query
|
||||
ORDER BY asset_important DESC, asset_name"
|
||||
);
|
||||
|
||||
while ($row = mysqli_fetch_array($asset_sql)) {
|
||||
$response['assets'][] = $row;
|
||||
}
|
||||
|
||||
echo json_encode($response);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns locations for a specified client
|
||||
*/
|
||||
if (isset($_GET['get_client_locations'])) {
|
||||
enforceUserPermission('module_client');
|
||||
|
||||
$client_id = intval($_GET['client_id']);
|
||||
|
||||
$locations_sql = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT location_id, location_name FROM locations
|
||||
LEFT JOIN clients on location_client_id = client_id
|
||||
WHERE locations.location_archived_at IS NULL AND location_client_id = $client_id
|
||||
$access_permission_query
|
||||
ORDER BY location_primary DESC, location_name ASC"
|
||||
);
|
||||
|
||||
while ($row = mysqli_fetch_array($locations_sql)) {
|
||||
$response['locations'][] = $row;
|
||||
}
|
||||
|
||||
echo json_encode($response);
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns ordered list of vendors for a specified client
|
||||
*/
|
||||
if (isset($_GET['get_client_vendors'])) {
|
||||
enforceUserPermission('module_client');
|
||||
|
||||
$client_id = intval($_GET['client_id']);
|
||||
|
||||
$vendors_sql = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT vendor_id, vendor_name FROM vendors
|
||||
LEFT JOIN clients on vendor_client_id = client_id
|
||||
WHERE vendors.vendor_archived_at IS NULL AND vendor_client_id = $client_id
|
||||
$access_permission_query
|
||||
ORDER BY vendor_name ASC"
|
||||
);
|
||||
|
||||
while ($row = mysqli_fetch_array($vendors_sql)) {
|
||||
$response['vendors'][] = $row;
|
||||
}
|
||||
|
||||
echo json_encode($response);
|
||||
}
|
||||
|
||||
/*
|
||||
* NEW TOTP getter for client login/passwords page
|
||||
* When provided with a login ID, checks permissions and returns the 6-digit code
|
||||
*/
|
||||
if (isset($_GET['get_totp_token_via_id'])) {
|
||||
enforceUserPermission('module_credential');
|
||||
|
||||
$credential_id = intval($_GET['credential_id']);
|
||||
|
||||
$sql = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT credential_name, credential_otp_secret, credential_client_id FROM credentials WHERE credential_id = $credential_id"));
|
||||
$name = sanitizeInput($sql['credential_name']);
|
||||
$totp_secret = $sql['credential_otp_secret'];
|
||||
$client_id = intval($sql['credential_client_id']);
|
||||
|
||||
$otp = TokenAuth6238::getTokenCode(strtoupper($totp_secret));
|
||||
echo json_encode($otp);
|
||||
|
||||
// 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
|
||||
$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)"));
|
||||
$recent_totp_view_logged_count = intval($check_recent_totp_view_logged_sql['recent_totp_view']);
|
||||
|
||||
if ($recent_totp_view_logged_count == 0) {
|
||||
// Logging
|
||||
logAction("Credential", "View TOTP", "$session_name viewed credential TOTP code for $name", $client_id, $credential_id);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_GET['get_readable_pass'])) {
|
||||
echo json_encode(GenerateReadablePassword(4));
|
||||
}
|
||||
|
||||
/*
|
||||
* ITFlow - POST request handler for client tickets
|
||||
*/
|
||||
if (isset($_POST['update_kanban_status_position'])) {
|
||||
// Update multiple ticket status kanban orders
|
||||
enforceUserPermission('module_support', 2);
|
||||
|
||||
$positions = $_POST['positions'];
|
||||
|
||||
foreach ($positions as $position) {
|
||||
$status_id = intval($position['status_id']);
|
||||
$kanban = intval($position['status_kanban']);
|
||||
|
||||
mysqli_query($mysqli, "UPDATE ticket_statuses SET ticket_status_order = $kanban WHERE ticket_status_id = $status_id");
|
||||
}
|
||||
|
||||
// return a response
|
||||
echo json_encode(['status' => 'success']);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (isset($_POST['update_kanban_ticket'])) {
|
||||
// Update ticket kanban order and status
|
||||
enforceUserPermission('module_support', 2);
|
||||
|
||||
// all tickets on the column
|
||||
$positions = $_POST['positions'];
|
||||
|
||||
foreach ($positions as $position) {
|
||||
$ticket_id = intval($position['ticket_id']);
|
||||
$kanban = intval($position['ticket_order']); // ticket kanban position
|
||||
$status = intval($position['ticket_status']); // ticket statuses
|
||||
$oldStatus = intval($position['ticket_oldStatus']); // ticket old status if moved
|
||||
|
||||
$statuses['Closed'] = 5;
|
||||
$statuses['Resolved'] = 4;
|
||||
|
||||
// Continue if status is null / Closed
|
||||
if ($status === null || $status === $statuses['Closed']) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
if ($oldStatus === false) {
|
||||
// if ticket was not moved, just uptdate the order on kanban
|
||||
mysqli_query($mysqli, "UPDATE tickets SET ticket_order = $kanban WHERE ticket_id = $ticket_id");
|
||||
customAction('ticket_update', $ticket_id);
|
||||
} else {
|
||||
// If the ticket was moved from a resolved status to another status, we need to update ticket_resolved_at
|
||||
if ($oldStatus === $statuses['Resolved']) {
|
||||
mysqli_query($mysqli, "UPDATE tickets SET ticket_order = $kanban, ticket_status = $status, ticket_resolved_at = NULL WHERE ticket_id = $ticket_id");
|
||||
customAction('ticket_update', $ticket_id);
|
||||
} elseif ($status === $statuses['Resolved']) {
|
||||
// If the ticket was moved to a resolved status, we need to update ticket_resolved_at
|
||||
mysqli_query($mysqli, "UPDATE tickets SET ticket_order = $kanban, ticket_status = $status, ticket_resolved_at = NOW() WHERE ticket_id = $ticket_id");
|
||||
customAction('ticket_update', $ticket_id);
|
||||
|
||||
// Client notification email
|
||||
if (!empty($config_smtp_host) && $config_ticket_client_general_notifications == 1) {
|
||||
|
||||
// Get details
|
||||
$ticket_sql = mysqli_query($mysqli, "SELECT contact_name, contact_email, ticket_prefix, ticket_number, ticket_subject, ticket_status_name, ticket_assigned_to, ticket_url_key, ticket_client_id FROM tickets
|
||||
LEFT JOIN clients ON ticket_client_id = client_id
|
||||
LEFT JOIN contacts ON ticket_contact_id = contact_id
|
||||
LEFT JOIN ticket_statuses ON ticket_status = ticket_status_id
|
||||
WHERE ticket_id = $ticket_id
|
||||
");
|
||||
$row = mysqli_fetch_array($ticket_sql);
|
||||
|
||||
$contact_name = sanitizeInput($row['contact_name']);
|
||||
$contact_email = sanitizeInput($row['contact_email']);
|
||||
$ticket_prefix = sanitizeInput($row['ticket_prefix']);
|
||||
$ticket_number = intval($row['ticket_number']);
|
||||
$ticket_subject = sanitizeInput($row['ticket_subject']);
|
||||
$client_id = intval($row['ticket_client_id']);
|
||||
$ticket_assigned_to = intval($row['ticket_assigned_to']);
|
||||
$ticket_status = sanitizeInput($row['ticket_status_name']);
|
||||
$url_key = sanitizeInput($row['ticket_url_key']);
|
||||
|
||||
// Sanitize Config vars from load_global_settings.php
|
||||
$config_ticket_from_name = sanitizeInput($config_ticket_from_name);
|
||||
$config_ticket_from_email = sanitizeInput($config_ticket_from_email);
|
||||
$config_base_url = sanitizeInput($config_base_url);
|
||||
|
||||
// Get Company Info
|
||||
$sql = mysqli_query($mysqli, "SELECT company_name, company_phone, company_phone_country_code FROM companies WHERE company_id = 1");
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$company_name = sanitizeInput($row['company_name']);
|
||||
$company_phone = sanitizeInput(formatPhoneNumber($row['company_phone'], $row['company_phone_country_code']));
|
||||
|
||||
// EMAIL
|
||||
$subject = "Ticket resolved - [$ticket_prefix$ticket_number] - $ticket_subject | (pending closure)";
|
||||
$body = "<i style=\'color: #808080\'>##- Please type your reply above this line -##</i><br><br>Hello $contact_name,<br><br>Your ticket regarding $ticket_subject has been marked as solved and is pending closure.<br><br>If your request/issue is resolved, you can simply ignore this email. If you need further assistance, please reply or <a href=\'https://$config_base_url/guest/guest_view_ticket.php?ticket_id=$ticket_id&url_key=$url_key\'>re-open</a> to let us know! <br><br>Ticket: $ticket_prefix$ticket_number<br>Subject: $ticket_subject<br>Status: $ticket_status<br>Portal: <a href=\'https://$config_base_url/guest/guest_view_ticket.php?ticket_id=$ticket_id&url_key=$url_key\'>View ticket</a><br><br>--<br>$company_name - Support<br>$config_ticket_from_email<br>$company_phone";
|
||||
|
||||
// Check email valid
|
||||
if (filter_var($contact_email, FILTER_VALIDATE_EMAIL)) {
|
||||
|
||||
$data = [];
|
||||
|
||||
// Email Ticket Contact
|
||||
// Queue Mail
|
||||
|
||||
$data[] = [
|
||||
'from' => $config_ticket_from_email,
|
||||
'from_name' => $config_ticket_from_name,
|
||||
'recipient' => $contact_email,
|
||||
'recipient_name' => $contact_name,
|
||||
'subject' => $subject,
|
||||
'body' => $body
|
||||
];
|
||||
}
|
||||
|
||||
// Also Email all the watchers
|
||||
$sql_watchers = mysqli_query($mysqli, "SELECT watcher_email FROM ticket_watchers WHERE watcher_ticket_id = $ticket_id");
|
||||
$body .= "<br><br>----------------------------------------<br>YOU ARE A COLLABORATOR ON THIS TICKET";
|
||||
while ($row = mysqli_fetch_array($sql_watchers)) {
|
||||
$watcher_email = sanitizeInput($row['watcher_email']);
|
||||
|
||||
// Queue Mail
|
||||
$data[] = [
|
||||
'from' => $config_ticket_from_email,
|
||||
'from_name' => $config_ticket_from_name,
|
||||
'recipient' => $watcher_email,
|
||||
'recipient_name' => $watcher_email,
|
||||
'subject' => $subject,
|
||||
'body' => $body
|
||||
];
|
||||
}
|
||||
addToMailQueue($data);
|
||||
}
|
||||
//End Mail IF
|
||||
|
||||
} else {
|
||||
// If the ticket was moved from any status to another status
|
||||
mysqli_query($mysqli, "UPDATE tickets SET ticket_order = $kanban, ticket_status = $status WHERE ticket_id = $ticket_id");
|
||||
customAction('ticket_update', $ticket_id);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// return a response
|
||||
echo json_encode(['status' => 'success','payload' => $positions]);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (isset($_POST['update_ticket_tasks_order'])) {
|
||||
// Update multiple ticket tasks order
|
||||
enforceUserPermission('module_support', 2);
|
||||
|
||||
$positions = $_POST['positions'];
|
||||
$ticket_id = intval($_POST['ticket_id']);
|
||||
|
||||
foreach ($positions as $position) {
|
||||
$id = intval($position['id']);
|
||||
$order = intval($position['order']);
|
||||
|
||||
mysqli_query($mysqli, "UPDATE tasks SET task_order = $order WHERE task_ticket_id = $ticket_id AND task_id = $id");
|
||||
}
|
||||
|
||||
// return a response
|
||||
echo json_encode(['status' => 'success']);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (isset($_POST['update_task_templates_order'])) {
|
||||
// Update multiple task templates order
|
||||
enforceUserPermission('module_support', 2);
|
||||
|
||||
$positions = $_POST['positions'];
|
||||
$ticket_template_id = intval($_POST['ticket_template_id']);
|
||||
|
||||
foreach ($positions as $position) {
|
||||
$id = intval($position['id']);
|
||||
$order = intval($position['order']);
|
||||
|
||||
mysqli_query($mysqli, "UPDATE task_templates SET task_template_order = $order WHERE task_template_ticket_template_id = $ticket_template_id AND task_template_id = $id");
|
||||
}
|
||||
|
||||
// return a response
|
||||
echo json_encode(['status' => 'success']);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (isset($_POST['update_quote_items_order'])) {
|
||||
// Update multiple quote items order
|
||||
enforceUserPermission('module_sales', 2);
|
||||
|
||||
$positions = $_POST['positions'];
|
||||
$quote_id = intval($_POST['quote_id']);
|
||||
|
||||
foreach ($positions as $position) {
|
||||
$id = intval($position['id']);
|
||||
$order = intval($position['order']);
|
||||
|
||||
mysqli_query($mysqli, "UPDATE invoice_items SET item_order = $order WHERE item_quote_id = $quote_id AND item_id = $id");
|
||||
}
|
||||
|
||||
// return a response
|
||||
echo json_encode(['status' => 'success']);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (isset($_POST['update_invoice_items_order'])) {
|
||||
// Update multiple invoice items order
|
||||
enforceUserPermission('module_sales', 2);
|
||||
|
||||
$positions = $_POST['positions'];
|
||||
$invoice_id = intval($_POST['invoice_id']);
|
||||
|
||||
foreach ($positions as $position) {
|
||||
$id = intval($position['id']);
|
||||
$order = intval($position['order']);
|
||||
|
||||
mysqli_query($mysqli, "UPDATE invoice_items SET item_order = $order WHERE item_invoice_id = $invoice_id AND item_id = $id");
|
||||
}
|
||||
|
||||
// return a response
|
||||
echo json_encode(['status' => 'success']);
|
||||
exit;
|
||||
}
|
||||
|
||||
if (isset($_POST['update_recurring_invoice_items_order'])) {
|
||||
// Update multiple recurring invoice items order
|
||||
enforceUserPermission('module_sales', 2);
|
||||
|
||||
$positions = $_POST['positions'];
|
||||
$recurring_invoice_id = intval($_POST['recurring_invoice_id']);
|
||||
|
||||
foreach ($positions as $position) {
|
||||
$id = intval($position['id']);
|
||||
$order = intval($position['order']);
|
||||
|
||||
mysqli_query($mysqli, "UPDATE invoice_items SET item_order = $order WHERE item_recurring_invoice_id = $recurring_invoice_id AND item_id = $id");
|
||||
}
|
||||
|
||||
// return a response
|
||||
echo json_encode(['status' => 'success']);
|
||||
exit;
|
||||
}
|
||||
|
|
@ -3902,8 +3902,8 @@ if (LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION) {
|
|||
|
||||
// Set Recurring payment method with Stripe to the new saved_payment_id and update the method to Credit Card
|
||||
$sql_recurring_payments = mysqli_query($mysqli, "SELECT * FROM recurring_payments
|
||||
LEFT JOIN invoices ON recurring_payment_invoice_id = invoice_id
|
||||
LEFT JOIN client_saved_payment_methods ON saved_payment_client = invoice_client_id
|
||||
LEFT JOIN invoices ON recurring_payment_recurring_invoice_id = invoice_id
|
||||
LEFT JOIN client_saved_payment_methods ON saved_payment_client_id = invoice_client_id
|
||||
WHERE recurring_payment_method = 'Stripe'"
|
||||
);
|
||||
|
||||
|
|
@ -3935,8 +3935,7 @@ if (LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION) {
|
|||
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '2.3.1'");
|
||||
}
|
||||
|
||||
/* 2025-07-21 - JQ For next release Pauyment Provider Switch Over
|
||||
if (CURRENT_DATABASE_VERSION == '2.2.4') {
|
||||
if (CURRENT_DATABASE_VERSION == '2.3.1') {
|
||||
|
||||
// Delete all Recurring Payments that are Stripe
|
||||
mysqli_query($mysqli, "DELETE FROM recurring_payments WHERE recurring_payment_method = 'Stripe'");
|
||||
|
|
@ -3961,14 +3960,13 @@ if (LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION) {
|
|||
DROP `config_ai_api_key`
|
||||
");
|
||||
|
||||
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '2.2.5'");
|
||||
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '2.3.2'");
|
||||
}
|
||||
*/
|
||||
|
||||
// if (CURRENT_DATABASE_VERSION == '2.2.5') {
|
||||
// // Insert queries here required to update to DB version 2.2.6
|
||||
// if (CURRENT_DATABASE_VERSION == '2.3.2') {
|
||||
// // Insert queries here required to update to DB version 2.3.3
|
||||
// // Then, update the database to the next sequential version
|
||||
// mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '2.2.6'");
|
||||
// mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '2.3.3'");
|
||||
// }
|
||||
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -238,20 +238,6 @@
|
|||
<p>Quote</p>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="settings_online_payment.php" class="nav-link <?php echo (basename($_SERVER['PHP_SELF']) == 'settings_online_payment.php' ? 'active' : ''); ?>">
|
||||
<i class="nav-icon far fa-credit-card"></i>
|
||||
<p>Online Payment</p>
|
||||
</a>
|
||||
</li>
|
||||
<?php if ($config_stripe_enable) { ?>
|
||||
<li class="nav-item">
|
||||
<a href="settings_online_payment_clients.php" class="nav-link <?php echo (basename($_SERVER['PHP_SELF']) == 'settings_online_payment_clients.php' ? 'active' : ''); ?>">
|
||||
<i class="nav-icon far fa-credit-card"></i>
|
||||
<p>Payment/Stripe Clients</p>
|
||||
</a>
|
||||
</li>
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
<?php if ($config_module_enable_ticketing) { ?>
|
||||
<li class="nav-item">
|
||||
|
|
@ -267,12 +253,6 @@
|
|||
</a>
|
||||
</li>
|
||||
<?php } ?>
|
||||
<li class="nav-item">
|
||||
<a href="settings_ai.php" class="nav-link <?php echo (basename($_SERVER['PHP_SELF']) == 'settings_ai.php' ? 'active' : ''); ?>">
|
||||
<i class="nav-icon fas fa-robot"></i>
|
||||
<p>AI</p>
|
||||
</a>
|
||||
</li>
|
||||
<!-- Currently the only integration is the client portal SSO -->
|
||||
<?php if ($config_client_portal_enable) { ?>
|
||||
<li class="nav-item">
|
||||
|
|
|
|||
|
|
@ -1,77 +0,0 @@
|
|||
<?php
|
||||
|
||||
require_once "includes/inc_all_admin.php";
|
||||
?>
|
||||
|
||||
<div class="card card-dark">
|
||||
<div class="card-header py-3">
|
||||
<h3 class="card-title"><i class="fas fa-fw fa-robot mr-2"></i>AI</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form action="post.php" method="post" autocomplete="off">
|
||||
<input type="hidden" name="csrf_token" value="<?php echo $_SESSION['csrf_token'] ?>">
|
||||
|
||||
<div class="form-group">
|
||||
<label>AI Provider <strong class="text-danger">*</strong></label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-robot"></i></span>
|
||||
</div>
|
||||
<select class="form-control select2" name="provider">
|
||||
<option value="" <?php if($config_ai_enable == 0) { echo "selected"; } ?> >Disabled</option>
|
||||
<option <?php if($config_ai_provider == "Ollama") { echo "selected"; } ?> >Ollama</option>
|
||||
<option <?php if($config_ai_provider == "OpenAI") { echo "selected"; } ?> >OpenAI</option>
|
||||
<option <?php if($config_ai_provider == "LocalAI") { echo "selected"; } ?> >LocalAI</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>AI Model</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-robot"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="model" value="<?php echo nullable_htmlentities($config_ai_model); ?>" placeholder="ex gpt-4">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>URL</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-globe"></i></span>
|
||||
</div>
|
||||
<input type="url" class="form-control" name="url" value="<?php echo nullable_htmlentities($config_ai_url); ?>" placeholder="ex https://ai.company.ext/api">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>API Key</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-key"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="api_key" value="<?php echo nullable_htmlentities($config_ai_api_key); ?>" placeholder="Enter API key here">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<button type="submit" name="edit_ai_settings" class="btn btn-primary text-bold"><i class="fa fa-check mr-2"></i>Save</button>
|
||||
|
||||
</form>
|
||||
|
||||
<div class="mt-5">
|
||||
<h5>Test AI Rewording</h5>
|
||||
<textarea id="textInput" class="form-control tinymceAI mb-3" rows="10"></textarea>
|
||||
</div>
|
||||
|
||||
<script src="js/ai_reword.js"></script>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
require_once "../includes/footer.php";
|
||||
|
||||
|
|
@ -1,154 +0,0 @@
|
|||
<?php
|
||||
|
||||
require_once "includes/inc_all_admin.php";
|
||||
|
||||
?>
|
||||
|
||||
<div class="card card-dark">
|
||||
<div class="card-header py-3">
|
||||
<h3 class="card-title"><i class="fas fa-fw fa-credit-card mr-2"></i>Online Payment</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form action="post.php" method="post" autocomplete="off">
|
||||
<input type="hidden" name="csrf_token" value="<?php echo $_SESSION['csrf_token'] ?>">
|
||||
|
||||
<div class="form-group">
|
||||
<div class="custom-control custom-switch">
|
||||
<input type="checkbox" class="custom-control-input" name="config_stripe_enable" <?php if ($config_stripe_enable == 1) { echo "checked"; } ?> value="1" id="enableStripeSwitch">
|
||||
<label class="custom-control-label" for="enableStripeSwitch">Enable Stripe</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="<?php if ($config_stripe_enable == 0) { echo "d-none"; } ?>">
|
||||
|
||||
<div class="form-group">
|
||||
<label>Publishable key <strong class="text-danger">*</strong></label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-eye"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="config_stripe_publishable" placeholder="Stripe Publishable API Key (pk_...)" value="<?php echo nullable_htmlentities($config_stripe_publishable); ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Secret key <strong class="text-danger">*</strong></label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-key"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="config_stripe_secret" placeholder="Stripe Secret API Key (sk_...)" value="<?php echo nullable_htmlentities($config_stripe_secret); ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Account <strong class="text-danger">*</strong></label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fas fa-fw fa-piggy-bank"></i></span>
|
||||
</div>
|
||||
<select class="form-control select2" name="config_stripe_account">
|
||||
<option value="">- Account -</option>
|
||||
<?php
|
||||
$sql_accounts = mysqli_query($mysqli, "SELECT * FROM accounts WHERE account_archived_at IS NULL ORDER BY account_name ASC");
|
||||
while ($row = mysqli_fetch_array($sql_accounts)) {
|
||||
$account_id = intval($row['account_id']);
|
||||
$account_name = nullable_htmlentities($row['account_name']);
|
||||
?>
|
||||
|
||||
<option value="<?php echo $account_id ?>" <?php if ($account_id == $config_stripe_account) { echo "selected"; } ?>><?php echo $account_name ?></option>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Expense 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="config_stripe_expense_vendor">
|
||||
<option value="">- Do not expense Stripe fees -</option>
|
||||
<?php
|
||||
|
||||
$sql_select = mysqli_query($mysqli, "SELECT vendor_id, vendor_name FROM vendors WHERE vendor_client_id = 0 AND vendor_archived_at IS NULL ORDER BY vendor_name ASC");
|
||||
while ($row = mysqli_fetch_array($sql_select)) {
|
||||
$vendor_id = intval($row['vendor_id']);
|
||||
$vendor_name = nullable_htmlentities($row['vendor_name']);
|
||||
?>
|
||||
<option <?php if ($config_stripe_expense_vendor == $vendor_id) { ?> selected <?php } ?> value="<?php echo $vendor_id; ?>"><?php echo $vendor_name; ?></option>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Expense Category</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-list"></i></span>
|
||||
</div>
|
||||
<select class="form-control select2" name="config_stripe_expense_category">
|
||||
<option value="">- Do not expense Stripe fees -</option>
|
||||
<?php
|
||||
|
||||
$sql_select = mysqli_query($mysqli, "SELECT category_id, category_name FROM categories WHERE category_type = 'Expense' AND category_archived_at IS NULL ORDER BY category_name ASC");
|
||||
while ($row = mysqli_fetch_array($sql_select)) {
|
||||
$category_id = intval($row['category_id']);
|
||||
$category_name = nullable_htmlentities($row['category_name']);
|
||||
?>
|
||||
<option <?php if ($config_stripe_expense_category == $category_id) { ?> selected <?php } ?> value="<?php echo $category_id; ?>"><?php echo $category_name; ?></option>
|
||||
<?php
|
||||
}
|
||||
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Percentage Fee to expense</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-percent"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" inputmode="numeric" pattern="[0-9]*\.?[0-9]{0,2}" name="config_stripe_percentage_fee" placeholder="Enter Percentage" value="<?php echo $config_stripe_percentage_fee * 100; ?>">
|
||||
</div>
|
||||
<small class="form-text text-muted">See <a href="https://stripe.com/pricing" target="_blank">here <i class="fas fa-fw fa-external-link-alt"></i></a> for the latest Stripe Fees.</small>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Flat Fee to expense</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" inputmode="numeric" pattern="[0-9]*\.?[0-9]{0,2}" name="config_stripe_flat_fee" placeholder="0.030" value="<?php echo number_format($config_stripe_flat_fee, 2, '.', ''); ?>">
|
||||
</div>
|
||||
<small class="form-text text-muted">See <a href="https://stripe.com/pricing" target="_blank">here <i class="fas fa-fw fa-external-link-alt"></i></a> for the latest Stripe Fees.</small>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="alert alert-secondary">Currently, we only integrate with Stripe. Please see <a href="https://forum.itflow.org/d/439-payment-integrations-megathread" target="_blank">this forum post</a>.</div>
|
||||
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
|
||||
<button type="submit" name="edit_online_payment_settings" class="btn btn-primary text-bold"><i class="fas fa-check mr-2"></i>Save</button>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
require_once "../includes/footer.php";
|
||||
|
||||
|
|
@ -1,77 +0,0 @@
|
|||
<?php
|
||||
|
||||
require_once "includes/inc_all_admin.php";
|
||||
|
||||
$stripe_clients_sql = mysqli_query($mysqli, "SELECT * FROM client_stripe LEFT JOIN clients ON client_stripe.client_id = clients.client_id");
|
||||
?>
|
||||
|
||||
<div class="card card-dark">
|
||||
<div class="card-header py-3">
|
||||
<h3 class="card-title"><i class="fas fa-fw fa-credit-card mr-2"></i>Online Payment - Client info</h3>
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table border border-dark">
|
||||
<thead class="thead-dark text-nowrap">
|
||||
<tr>
|
||||
<th>Client</th>
|
||||
<th>Stripe Customer ID</th>
|
||||
<th>Stripe Payment ID</th>
|
||||
<th>Payment Details</th>
|
||||
<th>Created</th>
|
||||
<th class="text-center">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
|
||||
<?php
|
||||
while ($row = mysqli_fetch_array($stripe_clients_sql)) {
|
||||
$client_id = intval($row['client_id']);
|
||||
$client_name = nullable_htmlentities($row['client_name']);
|
||||
$stripe_id = nullable_htmlentities($row['stripe_id']);
|
||||
$stripe_pm = nullable_htmlentities($row['stripe_pm']);
|
||||
$stripe_pm_details = nullable_htmlentities($row['stripe_pm_details']);
|
||||
$stripe_pm_created_at = nullable_htmlentities($row['stripe_pm_created_at']);
|
||||
|
||||
?>
|
||||
|
||||
<tr>
|
||||
<td><?php echo "$client_name ($client_id)"; ?></td>
|
||||
<td><?php echo $stripe_id; ?></td>
|
||||
<td><?php echo $stripe_pm; ?></td>
|
||||
<td><?php echo $stripe_pm_details; ?></td>
|
||||
<td><?php echo $stripe_pm_created_at; ?></td>
|
||||
<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">
|
||||
<?php if (!empty($stripe_pm)) { ?>
|
||||
<a class="dropdown-item text-danger confirm-link" href="post.php?stripe_remove_pm&client_id=<?php echo $client_id ?>&pm=<?php echo $stripe_pm ?>&csrf_token=<?php echo $_SESSION['csrf_token'] ?>">
|
||||
<i class="fas fa-fw fa-credit-card mr-2"></i>Delete payment method
|
||||
</a>
|
||||
<?php } else { ?>
|
||||
<a data-toggle="tooltip" data-placement="left" title="May result in duplicate customer records in Stripe" class="dropdown-item text-danger confirm-link" href="post.php?stripe_reset_customer&client_id=<?php echo $client_id ?>&csrf_token=<?php echo $_SESSION['csrf_token'] ?>">
|
||||
<i class="fas fa-fw fa-trash mr-2"></i>Reset Stripe
|
||||
</a>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<?php
|
||||
require_once "../includes/footer.php";
|
||||
32
db.sql
32
db.sql
|
|
@ -553,23 +553,6 @@ CREATE TABLE `client_saved_payment_methods` (
|
|||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `client_stripe`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `client_stripe`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `client_stripe` (
|
||||
`client_id` int(11) NOT NULL,
|
||||
`stripe_id` varchar(255) NOT NULL,
|
||||
`stripe_pm` varchar(255) DEFAULT NULL,
|
||||
`stripe_pm_details` varchar(200) DEFAULT NULL,
|
||||
`stripe_pm_created_at` datetime NOT NULL DEFAULT current_timestamp(),
|
||||
PRIMARY KEY (`client_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `client_tags`
|
||||
--
|
||||
|
|
@ -2054,19 +2037,6 @@ CREATE TABLE `settings` (
|
|||
`config_enable_alert_domain_expire` tinyint(1) NOT NULL DEFAULT 1,
|
||||
`config_send_invoice_reminders` tinyint(1) NOT NULL DEFAULT 1,
|
||||
`config_invoice_overdue_reminders` varchar(200) DEFAULT NULL,
|
||||
`config_stripe_enable` tinyint(1) NOT NULL DEFAULT 0,
|
||||
`config_stripe_publishable` varchar(255) DEFAULT NULL,
|
||||
`config_stripe_secret` varchar(255) DEFAULT NULL,
|
||||
`config_stripe_account` int(11) NOT NULL DEFAULT 0,
|
||||
`config_stripe_expense_vendor` int(11) NOT NULL DEFAULT 0,
|
||||
`config_stripe_expense_category` int(11) NOT NULL DEFAULT 0,
|
||||
`config_stripe_percentage_fee` decimal(4,4) NOT NULL DEFAULT 0.0290,
|
||||
`config_ai_enable` tinyint(1) DEFAULT 0,
|
||||
`config_ai_provider` varchar(250) DEFAULT NULL,
|
||||
`config_ai_model` varchar(250) DEFAULT NULL,
|
||||
`config_ai_url` varchar(250) DEFAULT NULL,
|
||||
`config_ai_api_key` varchar(250) DEFAULT NULL,
|
||||
`config_stripe_flat_fee` decimal(15,2) NOT NULL DEFAULT 0.30,
|
||||
`config_azure_client_id` varchar(200) DEFAULT NULL,
|
||||
`config_azure_client_secret` varchar(200) DEFAULT NULL,
|
||||
`config_module_enable_itdoc` tinyint(1) NOT NULL DEFAULT 1,
|
||||
|
|
@ -2788,4 +2758,4 @@ CREATE TABLE `vendors` (
|
|||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||
|
||||
-- Dump completed on 2025-08-11 18:18:59
|
||||
-- Dump completed on 2025-08-28 11:43:32
|
||||
|
|
|
|||
|
|
@ -1,151 +0,0 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* ITFlow browser extension
|
||||
*
|
||||
* Fills login forms, matching on the site URL:
|
||||
* After installation and configuration of the extension, users can simply click the key to fill the form on the page
|
||||
* If the URL of the page matches a configured login URL in ITFlow, the username and password is filled.
|
||||
*
|
||||
* Technical details:-
|
||||
* First, review how ITFlow handles password encryption: https://itflow.org/docs.php?doc=logins
|
||||
* Users must enable the extension via their profile/settings.
|
||||
* An extension key is generated and stored in the users table, and provided to the user as a cookie every time they log in. Additionally, their PHP Session ID is also stored in the users table.
|
||||
* The extension passes this cookie on all requests it makes (to this page). We use the cookie/key to identify/verify the user.
|
||||
* We can then access the users PHP session data. This, alongside the user_encryption_session_key cookie they provide, allows login passwords to be decrypted.
|
||||
*
|
||||
*/
|
||||
|
||||
// Headers to allow extensions access (CORS)
|
||||
$chrome_id = "chrome-extension://afgpakhonllnmnomchjhidealcpmnegc";
|
||||
|
||||
if (isset($_SERVER['HTTP_ORIGIN'])) {
|
||||
if ($_SERVER['HTTP_ORIGIN'] == $chrome_id) {
|
||||
header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}");
|
||||
header('Access-Control-Allow-Credentials: true');
|
||||
}
|
||||
}
|
||||
|
||||
require_once "config.php";
|
||||
|
||||
require_once "functions.php";
|
||||
|
||||
|
||||
// IP & User Agent for logging
|
||||
$ip = santizeInput(getIP());
|
||||
$user_agent = santizeInput($_SERVER['HTTP_USER_AGENT']);
|
||||
|
||||
// Define wording for the user
|
||||
DEFINE("WORDING_ROLECHECK_FAILED", "ITFlow - You are not permitted to use this application!");
|
||||
DEFINE("WORDING_BAD_EXT_COOKIE_KEY", "ITFlow - You are not logged into ITFlow, do not have, or did not send the correct extension key cookie.");
|
||||
|
||||
|
||||
// Check user is logged in & has extension access
|
||||
// We're not using the PHP session as we don't want to potentially expose the session cookie with SameSite None
|
||||
if (!isset($_COOKIE['user_extension_key'])) {
|
||||
$data['found'] = "FALSE";
|
||||
$data['message'] = WORDING_BAD_EXT_COOKIE_KEY;
|
||||
echo json_encode($data);
|
||||
|
||||
// Logging
|
||||
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Login', log_action = 'Extension Failed', log_description = 'Failed login attempt using extension (get_credential.php)', log_ip = '$ip', log_user_agent = '$user_agent'");
|
||||
|
||||
exit();
|
||||
}
|
||||
|
||||
// User has a cookie set with that name, let's verify it.
|
||||
$user_extension_key = $_COOKIE['user_extension_key'];
|
||||
|
||||
// Check the key isn't empty, less than 17 characters or the word "disabled".
|
||||
if (empty($user_extension_key) || strlen($user_extension_key) < 16 || strtolower($user_extension_key) == "disabled") {
|
||||
$data['found'] = "FALSE";
|
||||
$data['message'] = WORDING_BAD_EXT_COOKIE_KEY;
|
||||
echo json_encode($data);
|
||||
|
||||
// Logging
|
||||
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Login', log_action = 'Extension Failed', log_description = 'Failed login attempt using extension (get_credential.php)', log_ip = '$ip', log_user_agent = '$user_agent'");
|
||||
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
// Cookie seems valid, see if we can associate it with a user ID
|
||||
$user_extension_key = mysqli_real_escape_string($mysqli, $_COOKIE['user_extension_key']);
|
||||
$auth_user = mysqli_query($mysqli, "SELECT * FROM users LEFT JOIN user_settings on users.user_id = user_settings.user_id WHERE user_extension_key = '$user_extension_key' LIMIT 1");
|
||||
$row = mysqli_fetch_array($auth_user);
|
||||
|
||||
// Check SQL query state
|
||||
if (mysqli_num_rows($auth_user) < 1 || !$auth_user) {
|
||||
$data['found'] = "FALSE";
|
||||
$data['message'] = WORDING_BAD_EXT_COOKIE_KEY;
|
||||
echo json_encode($data);
|
||||
|
||||
//Logging
|
||||
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Login', log_action = 'Extension Failed', log_description = 'Failed login attempt using extension (get_credential.php)', log_ip = '$ip', log_user_agent = '$user_agent'");
|
||||
|
||||
exit();
|
||||
}
|
||||
|
||||
// Sanity check
|
||||
if (hash('sha256', $row['user_extension_key']) !== hash('sha256', $_COOKIE['user_extension_key'])) {
|
||||
$data['found'] = "FALSE";
|
||||
$data['message'] = WORDING_BAD_EXT_COOKIE_KEY;
|
||||
echo json_encode($data);
|
||||
|
||||
//Logging
|
||||
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Login', log_action = 'Extension Failed', log_description = 'Failed login attempt using extension (get_credential.php)', log_ip = '$ip', log_user_agent = '$user_agent'");
|
||||
|
||||
exit();
|
||||
}
|
||||
|
||||
// Success - validated user cookie
|
||||
|
||||
// Get the current session from the database, so we can decrypt passwords
|
||||
session_id($row['user_php_session']);
|
||||
session_start();
|
||||
|
||||
$session_user_id = intval($row['user_id']);
|
||||
$session_name = $row['user_name'];
|
||||
$session_email = $row['user_email'];
|
||||
$session_user_role = $row['user_role'];
|
||||
|
||||
// Check user access level is correct (not an accountant)
|
||||
if ($session_user_role < 1) {
|
||||
$data['found'] = "FALSE";
|
||||
$data['message'] = WORDING_ROLECHECK_FAILED;
|
||||
echo json_encode($data);
|
||||
|
||||
//Logging
|
||||
$user_name = mysqli_real_escape_string($mysqli, $session_name);
|
||||
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Login', log_action = 'Extension Failed', log_description = '$user_name not authorised to use extension', log_ip = '$ip', log_user_agent = '$user_agent', log_user_id = $session_user_id");
|
||||
|
||||
exit();
|
||||
}
|
||||
|
||||
// Lets go!
|
||||
|
||||
if (isset($_GET['host'])) {
|
||||
|
||||
if (!empty($_GET['host'])) {
|
||||
$url = santizeInput($_GET['host']);
|
||||
|
||||
$sql_logins = mysqli_query($mysqli, "SELECT * FROM logins WHERE login_uri = '$url' LIMIT 1");
|
||||
|
||||
if (mysqli_num_rows($sql_logins) > 0) {
|
||||
$row = mysqli_fetch_array($sql_logins);
|
||||
$data['found'] = "TRUE";
|
||||
$data['username'] = nullable_htmlentities(decryptLoginEntry($row['login_username']));
|
||||
$data['password'] = decryptLoginEntry($row['login_password']); // Uses the PHP Session info and the session key cookie
|
||||
echo json_encode($data);
|
||||
|
||||
// Logging
|
||||
$login_name = sanitizeInput($row['login_name']);
|
||||
$login_user = sanitizeInput($row['login_username']);
|
||||
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Login', log_action = 'Extension requested', log_description = 'Credential $login_name, username $login_user', log_ip = '$ip', log_user_agent = '$user_agent', log_user_id = $session_user_id");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//TODO: Future work:-
|
||||
// - Showing multiple logins for a single URL
|
||||
|
|
@ -5,4 +5,4 @@
|
|||
* It is used in conjunction with database_updates.php
|
||||
*/
|
||||
|
||||
DEFINE("LATEST_DATABASE_VERSION", "2.3.1");
|
||||
DEFINE("LATEST_DATABASE_VERSION", "2.3.2");
|
||||
|
|
|
|||
|
|
@ -91,23 +91,6 @@ $config_enable_alert_domain_expire = intval($row['config_enable_alert_domain_exp
|
|||
$config_send_invoice_reminders = intval($row['config_send_invoice_reminders']);
|
||||
$config_invoice_overdue_reminders = intval($row['config_invoice_overdue_reminders']);
|
||||
|
||||
// Online Stripe Payment
|
||||
$config_stripe_enable = intval($row['config_stripe_enable']);
|
||||
$config_stripe_publishable = $row['config_stripe_publishable'];
|
||||
$config_stripe_secret = $row['config_stripe_secret'];
|
||||
$config_stripe_account = intval($row['config_stripe_account']);
|
||||
$config_stripe_expense_vendor = intval($row['config_stripe_expense_vendor']);
|
||||
$config_stripe_expense_category = intval($row['config_stripe_expense_category']);
|
||||
$config_stripe_percentage_fee = floatval($row['config_stripe_percentage_fee']);
|
||||
$config_stripe_flat_fee = floatval($row['config_stripe_flat_fee']);
|
||||
|
||||
// AI Provider Details
|
||||
$config_ai_enable = intval($row['config_ai_enable']);
|
||||
$config_ai_provider = $row['config_ai_provider'];
|
||||
$config_ai_model = $row['config_ai_model'];
|
||||
$config_ai_url = $row['config_ai_url'];
|
||||
$config_ai_api_key = $row['config_ai_api_key'];
|
||||
|
||||
// Modules
|
||||
$config_module_enable_itdoc = intval($row['config_module_enable_itdoc']);
|
||||
$config_module_enable_ticketing = intval($row['config_module_enable_ticketing']);
|
||||
|
|
|
|||
|
|
@ -81,15 +81,6 @@ $currency_format = numfmt_create($company_locale, NumberFormatter::CURRENCY);
|
|||
$config_whitelabel_enabled = intval($row['config_whitelabel_enabled']);
|
||||
$config_whitelabel_key = $row['config_whitelabel_key'];
|
||||
|
||||
// Online Stripe Payment
|
||||
$config_stripe_enable = intval($row['config_stripe_enable']);
|
||||
$config_stripe_secret = $row['config_stripe_secret'];
|
||||
$config_stripe_account = intval($row['config_stripe_account']);
|
||||
$config_stripe_expense_vendor = intval($row['config_stripe_expense_vendor']);
|
||||
$config_stripe_expense_category = intval($row['config_stripe_expense_category']);
|
||||
$config_stripe_percentage_fee = floatval($row['config_stripe_percentage_fee']);
|
||||
$config_stripe_flat_fee = floatval($row['config_stripe_flat_fee']);
|
||||
|
||||
// Check cron is enabled
|
||||
if ($config_enable_cron == 0) {
|
||||
exit("Cron: is not enabled -- Quitting..");
|
||||
|
|
|
|||
Loading…
Reference in New Issue