mirror of
https://github.com/itflow-org/itflow
synced 2026-08-09 17:17:14 +00:00
Query Optimization: Select only needed columns instead of SELECT * on looped queries
This commit is contained in:
@@ -6,7 +6,8 @@ $order = "ASC";
|
||||
|
||||
require_once "includes/inc_all_admin.php";
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM ai_models LEFT JOIN ai_providers ON ai_model_ai_provider_id = ai_provider_id ORDER BY $sort $order");
|
||||
$sql = mysqli_query($mysqli, "SELECT ai_model_id, ai_model_name, ai_model_prompt, ai_model_use_case, ai_provider_id,
|
||||
ai_provider_name FROM ai_models LEFT JOIN ai_providers ON ai_model_ai_provider_id = ai_provider_id ORDER BY $sort $order");
|
||||
|
||||
$num_rows = mysqli_num_rows($sql);
|
||||
|
||||
|
||||
@@ -48,7 +48,8 @@ if (isset($_GET['action']) & !empty($_GET['action'])) {
|
||||
|
||||
$sql = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT SQL_CALC_FOUND_ROWS * FROM logs
|
||||
"SELECT SQL_CALC_FOUND_ROWS client_id, client_name, log_action, log_created_at, log_description, log_entity_id, log_id,
|
||||
log_ip, log_type, log_user_agent, user_id, user_name FROM logs
|
||||
LEFT JOIN users ON log_user_id = user_id
|
||||
LEFT JOIN clients ON log_client_id = client_id
|
||||
WHERE (log_type LIKE '%$q%' OR log_action LIKE '%$q%' OR log_description LIKE '%$q%' OR log_ip LIKE '%$q%' OR log_user_agent LIKE '%$q%' OR user_name LIKE '%$q%' OR client_name LIKE '%$q%')
|
||||
@@ -87,7 +88,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
||||
<option value="">- All Clients -</option>
|
||||
|
||||
<?php
|
||||
$sql_clients_filter = mysqli_query($mysqli, "SELECT * FROM clients ORDER BY client_name ASC");
|
||||
$sql_clients_filter = mysqli_query($mysqli, "SELECT client_id, client_name FROM clients ORDER BY client_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_clients_filter)) {
|
||||
$client_id = intval($row['client_id']);
|
||||
$client_name = escapeHtml($row['client_name']);
|
||||
|
||||
@@ -19,7 +19,8 @@ $cron_is_running = $cron_last_dispatch_at !== null && (time() - strtotime($cron_
|
||||
|
||||
$backup_job = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT cron_job_enabled, cron_job_daily_at FROM cron_jobs WHERE cron_job_name = 'backup'"));
|
||||
|
||||
$backups = mysqli_query($mysqli, "SELECT * FROM backups ORDER BY backup_created_at DESC LIMIT 100");
|
||||
$backups = mysqli_query($mysqli, "SELECT backup_created_at, backup_error, backup_id, backup_size, backup_source, backup_status,
|
||||
backup_type FROM backups ORDER BY backup_created_at DESC LIMIT 100");
|
||||
|
||||
$pending_count = intval(mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT(*) AS c FROM backups WHERE backup_status IN ('Pending','Running')"))['c']);
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ foreach (cronJobRegistry() as $job) {
|
||||
$cron_jobs[$job['name']]['row'] = null;
|
||||
}
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM cron_jobs");
|
||||
$sql = mysqli_query($mysqli, "SELECT cron_job_name FROM cron_jobs");
|
||||
while ($job_row = mysqli_fetch_assoc($sql)) {
|
||||
if (isset($cron_jobs[$job_row['cron_job_name']])) {
|
||||
$cron_jobs[$job_row['cron_job_name']]['row'] = $job_row;
|
||||
|
||||
@@ -8,7 +8,8 @@ require_once "includes/inc_all_admin.php";
|
||||
|
||||
$sql = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT SQL_CALC_FOUND_ROWS * FROM custom_links
|
||||
"SELECT SQL_CALC_FOUND_ROWS custom_link_icon, custom_link_id, custom_link_location, custom_link_name,
|
||||
custom_link_new_tab, custom_link_order, custom_link_uri FROM custom_links
|
||||
WHERE custom_link_name LIKE '%$q%'
|
||||
ORDER BY $sort $order LIMIT $record_from, $record_to"
|
||||
);
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
|
||||
$sql = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT SQL_CALC_FOUND_ROWS * FROM document_templates
|
||||
"SELECT SQL_CALC_FOUND_ROWS document_template_content, document_template_created_at, document_template_description,
|
||||
document_template_id, document_template_name, document_template_updated_at, user_name FROM document_templates
|
||||
LEFT JOIN users ON document_template_created_by = user_id
|
||||
WHERE user_name LIKE '%$q%' OR document_template_name LIKE '%$q%'
|
||||
ORDER BY $sort $order LIMIT $record_from, $record_to"
|
||||
|
||||
@@ -314,7 +314,7 @@
|
||||
</li>
|
||||
|
||||
<?php
|
||||
$sql_custom_links = mysqli_query($mysqli, "SELECT * FROM custom_links
|
||||
$sql_custom_links = mysqli_query($mysqli, "SELECT custom_link_icon, custom_link_name, custom_link_new_tab, custom_link_uri FROM custom_links
|
||||
WHERE custom_link_location = 4 AND custom_link_archived_at IS NULL
|
||||
ORDER BY custom_link_order ASC, custom_link_name ASC"
|
||||
);
|
||||
|
||||
@@ -8,7 +8,8 @@ require_once "includes/inc_all_admin.php";
|
||||
|
||||
$sql = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT SQL_CALC_FOUND_ROWS * FROM email_queue
|
||||
"SELECT SQL_CALC_FOUND_ROWS email_attempts, email_failed_at, email_from, email_from_name, email_id, email_queued_at,
|
||||
email_recipient, email_recipient_name, email_sent_at, email_status, email_subject FROM email_queue
|
||||
WHERE (email_id LIKE '%$q%' OR email_from LIKE '%$q%' OR email_from_name LIKE '%$q%' OR email_recipient LIKE '%$q%' OR email_recipient_name LIKE '%$q%' OR email_subject LIKE '%$q%')
|
||||
AND DATE(email_queued_at) BETWEEN '$dtf' AND '$dtt'
|
||||
ORDER BY $sort $order LIMIT $record_from, $record_to"
|
||||
|
||||
@@ -60,7 +60,7 @@ ob_start();
|
||||
<option value="0">- No -</option>
|
||||
<?php
|
||||
|
||||
$sql_project_templates = mysqli_query($mysqli, "SELECT * FROM project_templates WHERE project_template_archived_at IS NULL ORDER BY project_template_name ASC");
|
||||
$sql_project_templates = mysqli_query($mysqli, "SELECT project_template_id, project_template_name FROM project_templates WHERE project_template_archived_at IS NULL ORDER BY project_template_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_project_templates)) {
|
||||
$project_template_id_select = intval($row['project_template_id']);
|
||||
$project_template_name_select = escapeHtml($row['project_template_name']); ?>
|
||||
|
||||
@@ -138,7 +138,7 @@ ob_start();
|
||||
<tbody>
|
||||
|
||||
<?php
|
||||
$sql_client_select = mysqli_query($mysqli, "SELECT * FROM clients WHERE client_archived_at IS NULL ORDER BY client_name ASC");
|
||||
$sql_client_select = mysqli_query($mysqli, "SELECT client_id, client_name FROM clients WHERE client_archived_at IS NULL ORDER BY client_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_client_select)) {
|
||||
$client_id = intval($row['client_id']);
|
||||
$client_name = escapeHtml($row['client_name']);
|
||||
|
||||
@@ -190,7 +190,7 @@ ob_start();
|
||||
<tbody>
|
||||
|
||||
<?php
|
||||
$sql_client_select = mysqli_query($mysqli, "SELECT * FROM clients WHERE client_archived_at IS NULL ORDER BY client_name ASC");
|
||||
$sql_client_select = mysqli_query($mysqli, "SELECT client_id, client_name FROM clients WHERE client_archived_at IS NULL ORDER BY client_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_client_select)) {
|
||||
$client_id_select = intval($row['client_id']);
|
||||
$client_name_select = escapeHtml($row['client_name']);
|
||||
|
||||
@@ -27,7 +27,9 @@ if (isset($_GET['project_template_id'])) {
|
||||
$project_template_updated_at = escapeHtml($row['project_template_updated_at']);
|
||||
|
||||
// Get Associated Ticket Templates
|
||||
$sql_ticket_templates = mysqli_query($mysqli, "SELECT * FROM ticket_templates, project_template_ticket_templates
|
||||
$sql_ticket_templates = mysqli_query($mysqli, "SELECT ticket_template_created_at, ticket_template_description,
|
||||
project_template_ticket_templates.ticket_template_id, ticket_template_name,
|
||||
ticket_template_order, ticket_template_subject, ticket_template_updated_at FROM ticket_templates, project_template_ticket_templates
|
||||
WHERE ticket_templates.ticket_template_id = project_template_ticket_templates.ticket_template_id
|
||||
AND project_template_ticket_templates.project_template_id = $project_template_id
|
||||
ORDER BY ticket_template_order ASC, ticket_template_name ASC");
|
||||
@@ -35,7 +37,7 @@ if (isset($_GET['project_template_id'])) {
|
||||
|
||||
// Get All Task Templates
|
||||
$sql_task_templates = mysqli_query($mysqli,
|
||||
"SELECT * FROM ticket_templates, task_templates, project_template_ticket_templates
|
||||
"SELECT task_template_id, task_template_name FROM ticket_templates, task_templates, project_template_ticket_templates
|
||||
WHERE ticket_templates.ticket_template_id = project_template_ticket_templates.ticket_template_id
|
||||
AND project_template_ticket_templates.project_template_id = $project_template_id
|
||||
AND ticket_templates.ticket_template_id = task_template_ticket_template_id
|
||||
|
||||
@@ -8,7 +8,8 @@ require_once "includes/inc_all_admin.php";
|
||||
|
||||
$sql = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT SQL_CALC_FOUND_ROWS * FROM project_templates
|
||||
"SELECT SQL_CALC_FOUND_ROWS project_template_created_at, project_template_description, project_template_id,
|
||||
project_template_name FROM project_templates
|
||||
WHERE (project_template_name LIKE '%$q%' OR project_template_description LIKE '%$q%')
|
||||
AND project_template_archived_at IS NULL
|
||||
ORDER BY $sort $order LIMIT $record_from, $record_to"
|
||||
|
||||
@@ -82,7 +82,7 @@ $net_terms_array = array (
|
||||
<option value="0">- None -</option>
|
||||
<?php
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM accounts WHERE account_archived_at IS NULL ORDER BY account_name ASC");
|
||||
$sql = mysqli_query($mysqli, "SELECT account_id, account_name FROM accounts WHERE account_archived_at IS NULL ORDER BY account_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql)) {
|
||||
$account_id = intval($row['account_id']);
|
||||
$account_name = escapeHtml($row['account_name']); ?>
|
||||
@@ -105,7 +105,7 @@ $net_terms_array = array (
|
||||
<option value="0">- None -</option>
|
||||
<?php
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM accounts WHERE account_archived_at IS NULL ORDER BY account_name ASC");
|
||||
$sql = mysqli_query($mysqli, "SELECT account_id, account_name FROM accounts WHERE account_archived_at IS NULL ORDER BY account_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql)) {
|
||||
$account_id = intval($row['account_id']);
|
||||
$account_name = escapeHtml($row['account_name']); ?>
|
||||
@@ -128,7 +128,7 @@ $net_terms_array = array (
|
||||
<option value="0">- None -</option>
|
||||
<?php
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM accounts WHERE account_archived_at IS NULL ORDER BY account_name ASC");
|
||||
$sql = mysqli_query($mysqli, "SELECT account_id, account_name FROM accounts WHERE account_archived_at IS NULL ORDER BY account_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql)) {
|
||||
$account_id = intval($row['account_id']);
|
||||
$account_name = escapeHtml($row['account_name']); ?>
|
||||
@@ -153,7 +153,7 @@ $net_terms_array = array (
|
||||
<option value="0">- None -</option>
|
||||
<?php
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM accounts WHERE account_archived_at IS NULL ORDER BY account_name ASC");
|
||||
$sql = mysqli_query($mysqli, "SELECT account_id, account_name FROM accounts WHERE account_archived_at IS NULL ORDER BY account_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql)) {
|
||||
$account_id = intval($row['account_id']);
|
||||
$account_name = escapeHtml($row['account_name']); ?>
|
||||
|
||||
@@ -8,7 +8,9 @@ require_once "includes/inc_all_admin.php";
|
||||
|
||||
$sql = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT SQL_CALC_FOUND_ROWS * FROM software_templates
|
||||
"SELECT SQL_CALC_FOUND_ROWS software_template_description, software_template_id, software_template_license_type,
|
||||
software_template_name, software_template_notes, software_template_type,
|
||||
software_template_version FROM software_templates
|
||||
WHERE software_template_name LIKE '%$q%' OR software_template_type LIKE '%$q%'
|
||||
ORDER BY $sort $order LIMIT $record_from, $record_to"
|
||||
);
|
||||
|
||||
@@ -8,7 +8,10 @@ require_once "includes/inc_all_admin.php";
|
||||
|
||||
$sql = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT SQL_CALC_FOUND_ROWS * FROM vendor_templates
|
||||
"SELECT SQL_CALC_FOUND_ROWS vendor_template_account_number, vendor_template_code, vendor_template_contact_name,
|
||||
vendor_template_description, vendor_template_email, vendor_template_extension,
|
||||
vendor_template_hours, vendor_template_id, vendor_template_name, vendor_template_notes,
|
||||
vendor_template_phone, vendor_template_sla, vendor_template_website FROM vendor_templates
|
||||
WHERE vendor_template_name LIKE '%$q%' OR vendor_template_description LIKE '%$q%' OR vendor_template_account_number LIKE '%$q%' OR vendor_template_website LIKE '%$q%' OR vendor_template_contact_name LIKE '%$q%' OR vendor_template_email LIKE '%$q%' OR vendor_template_phone LIKE '%$phone_query%' ORDER BY $sort $order LIMIT $record_from, $record_to"
|
||||
);
|
||||
|
||||
|
||||
@@ -206,7 +206,8 @@ if (isset($_GET['asset_id'])) {
|
||||
}
|
||||
|
||||
// Related Documents
|
||||
$sql_related_documents = mysqli_query($mysqli, "SELECT * FROM asset_documents, documents
|
||||
$sql_related_documents = mysqli_query($mysqli, "SELECT document_created_at, document_description, documents.document_id, document_name,
|
||||
document_updated_at, user_name FROM asset_documents, documents
|
||||
LEFT JOIN users ON document_created_by = user_id
|
||||
WHERE asset_documents.asset_id = $asset_id
|
||||
AND asset_documents.document_id = documents.document_id
|
||||
@@ -253,7 +254,8 @@ if (isset($_GET['asset_id'])) {
|
||||
$software_count = mysqli_num_rows($sql_related_software);
|
||||
|
||||
// Linked Services
|
||||
$sql_linked_services = mysqli_query($mysqli, "SELECT * FROM service_assets, services
|
||||
$sql_linked_services = mysqli_query($mysqli, "SELECT service_category, service_description, service_assets.service_id, service_importance,
|
||||
service_name FROM service_assets, services
|
||||
WHERE service_assets.asset_id = $asset_id
|
||||
AND service_assets.service_id = services.service_id
|
||||
ORDER BY service_name ASC"
|
||||
@@ -263,7 +265,7 @@ if (isset($_GET['asset_id'])) {
|
||||
$linked_services = array();
|
||||
|
||||
// Notes - 1 to many relationship
|
||||
$sql_related_notes = mysqli_query($mysqli, "SELECT * FROM asset_notes
|
||||
$sql_related_notes = mysqli_query($mysqli, "SELECT asset_note, asset_note_created_at, asset_note_id, asset_note_type, user_name FROM asset_notes
|
||||
LEFT JOIN users ON asset_note_created_by = user_id
|
||||
WHERE asset_note_asset_id = $asset_id
|
||||
AND asset_note_archived_at IS NULL
|
||||
|
||||
@@ -150,7 +150,14 @@ $other_count = intval($row['other_count']);
|
||||
|
||||
$sql = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT SQL_CALC_FOUND_ROWS * FROM assets
|
||||
"SELECT SQL_CALC_FOUND_ROWS asset_archived_at, asset_contact_id, asset_created_at, asset_description, asset_favorite,
|
||||
asset_id, asset_install_date, asset_location_id, asset_make, asset_model, asset_name,
|
||||
asset_notes, asset_os, asset_photo, asset_physical_location, asset_purchase_date,
|
||||
asset_purchase_reference, asset_serial, asset_status, asset_type, asset_uri, asset_uri_2,
|
||||
asset_uri_client, asset_vendor_id, asset_warranty_expire, client_id, client_name,
|
||||
contact_archived_at, contact_name, interface_ip, interface_ipv6, interface_mac,
|
||||
interface_nat_ip, interface_network_id, location_archived_at, location_name, tag_color,
|
||||
tag_icon, tag_id, tag_name FROM assets
|
||||
LEFT JOIN clients ON asset_client_id = client_id
|
||||
LEFT JOIN contacts ON asset_contact_id = contact_id
|
||||
LEFT JOIN locations ON asset_location_id = location_id
|
||||
|
||||
@@ -135,7 +135,8 @@ if (isset($_GET['calendar_id'])) {
|
||||
require_once "modals/calendar/calendar_event_add.php";
|
||||
|
||||
//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 calendar_color, calendar_id, calendar_name, event_client_id, event_description, event_end,
|
||||
event_id, event_location, event_repeat, event_start, event_title FROM calendar_events LEFT JOIN calendars ON event_calendar_id = calendar_id $client_event_query");
|
||||
while ($row = mysqli_fetch_assoc($sql)) {
|
||||
$event_id = intval($row['event_id']);
|
||||
$event_title = escapeHtml($row['event_title']);
|
||||
@@ -303,7 +304,8 @@ while ($row = mysqli_fetch_assoc($sql)) {
|
||||
},
|
||||
events: [
|
||||
<?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 calendar_color, calendar_id, calendar_name, event_all_day, event_id, event_repeat,
|
||||
event_title FROM calendar_events LEFT JOIN calendars ON event_calendar_id = calendar_id $client_event_query");
|
||||
|
||||
// Repeating events are stored as a single row, so the occurrences have to
|
||||
// be materialised here - the bundled FullCalendar build has no rrule
|
||||
@@ -341,7 +343,7 @@ while ($row = mysqli_fetch_assoc($sql)) {
|
||||
}
|
||||
|
||||
// Invoices Created
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM clients LEFT JOIN invoices ON client_id = invoice_client_id $client_query " . clientScopeSql('clients.client_id') . "");
|
||||
$sql = mysqli_query($mysqli, "SELECT invoice_date, invoice_id, invoice_number, invoice_prefix, invoice_scope FROM clients LEFT JOIN invoices ON client_id = invoice_client_id $client_query " . clientScopeSql('clients.client_id') . "");
|
||||
while ($row = mysqli_fetch_assoc($sql)) {
|
||||
$event_id = intval($row['invoice_id']);
|
||||
$scope = strval($row['invoice_scope']);
|
||||
@@ -356,7 +358,7 @@ while ($row = mysqli_fetch_assoc($sql)) {
|
||||
}
|
||||
|
||||
// Quotes Created
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM clients LEFT JOIN quotes ON client_id = quote_client_id $client_query " . clientScopeSql('clients.client_id') . "");
|
||||
$sql = mysqli_query($mysqli, "SELECT quote_date, quote_id, quote_number, quote_prefix, quote_scope FROM clients LEFT JOIN quotes ON client_id = quote_client_id $client_query " . clientScopeSql('clients.client_id') . "");
|
||||
while ($row = mysqli_fetch_assoc($sql)) {
|
||||
$event_id = intval($row['quote_id']);
|
||||
$event_title = json_encode($row['quote_prefix'] . $row['quote_number'] . " " . $row['quote_scope']);
|
||||
@@ -366,7 +368,8 @@ while ($row = mysqli_fetch_assoc($sql)) {
|
||||
}
|
||||
|
||||
// Tickets Created
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM clients
|
||||
$sql = mysqli_query($mysqli, "SELECT ticket_created_at, ticket_id, ticket_number, ticket_prefix, ticket_status,
|
||||
ticket_status_name, ticket_subject, user_name FROM clients
|
||||
LEFT JOIN tickets ON client_id = ticket_client_id
|
||||
LEFT JOIN ticket_statuses ON ticket_status = ticket_status_id
|
||||
LEFT JOIN users ON ticket_assigned_to = user_id
|
||||
@@ -401,7 +404,8 @@ while ($row = mysqli_fetch_assoc($sql)) {
|
||||
}
|
||||
|
||||
// Recurring Tickets
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM clients
|
||||
$sql = mysqli_query($mysqli, "SELECT client_id, recurring_ticket_frequency, recurring_ticket_id, recurring_ticket_next_run,
|
||||
recurring_ticket_subject, user_name FROM clients
|
||||
LEFT JOIN recurring_tickets ON client_id = recurring_ticket_client_id
|
||||
LEFT JOIN users ON recurring_ticket_assigned_to = user_id
|
||||
$client_query " . clientScopeSql('clients.client_id') . ""
|
||||
@@ -425,7 +429,8 @@ while ($row = mysqli_fetch_assoc($sql)) {
|
||||
}
|
||||
|
||||
// Tickets Scheduled
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM clients
|
||||
$sql = mysqli_query($mysqli, "SELECT ticket_id, ticket_number, ticket_prefix, ticket_schedule, ticket_status_name,
|
||||
ticket_subject, user_name FROM clients
|
||||
LEFT JOIN tickets ON client_id = ticket_client_id
|
||||
LEFT JOIN ticket_statuses ON ticket_status = ticket_status_id
|
||||
LEFT JOIN users ON ticket_assigned_to = user_id
|
||||
@@ -460,7 +465,7 @@ while ($row = mysqli_fetch_assoc($sql)) {
|
||||
}
|
||||
|
||||
// Vendors Added Created
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM clients LEFT JOIN vendors ON client_id = vendor_client_id $client_query " . clientScopeSql('clients.client_id') . "");
|
||||
$sql = mysqli_query($mysqli, "SELECT client_id, vendor_created_at, vendor_id, vendor_name FROM clients LEFT JOIN vendors ON client_id = vendor_client_id $client_query " . clientScopeSql('clients.client_id') . "");
|
||||
while ($row = mysqli_fetch_assoc($sql)) {
|
||||
$event_id = intval($row['vendor_id']);
|
||||
$client_id = intval($row['client_id']);
|
||||
@@ -472,7 +477,7 @@ while ($row = mysqli_fetch_assoc($sql)) {
|
||||
|
||||
if (!isset($_GET['client_id'])) {
|
||||
//Clients Added
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM clients");
|
||||
$sql = mysqli_query($mysqli, "SELECT client_created_at, client_id, client_name FROM clients");
|
||||
while ($row = mysqli_fetch_assoc($sql)) {
|
||||
$event_id = intval($row['client_id']);
|
||||
$event_title = json_encode("Client: '" . $row['client_name'] . "' created");
|
||||
|
||||
@@ -61,7 +61,9 @@ if (!$client_url) {
|
||||
}
|
||||
}
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT SQL_CALC_FOUND_ROWS * FROM certificates
|
||||
$sql = mysqli_query($mysqli, "SELECT SQL_CALC_FOUND_ROWS certificate_archived_at, certificate_created_at, certificate_description,
|
||||
certificate_domain, certificate_expire, certificate_id, certificate_issued_by,
|
||||
certificate_name, client_id, client_name FROM certificates
|
||||
LEFT JOIN clients ON client_id = certificate_client_id
|
||||
WHERE $archive_query
|
||||
AND (certificate_name LIKE '%$q%' OR certificate_domain LIKE '%$q%' OR certificate_description LIKE '%$q%' OR certificate_issued_by LIKE '%$q%' OR client_name LIKE '%$q%')
|
||||
|
||||
@@ -12,7 +12,9 @@ $sql_recent_activities = mysqli_query(
|
||||
|
||||
$sql_important_contacts = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT * FROM contacts
|
||||
"SELECT contact_email, contact_extension, contact_id, contact_mobile, contact_mobile_country_code,
|
||||
contact_name, contact_phone, contact_phone_country_code, contact_photo, contact_primary,
|
||||
contact_title FROM contacts
|
||||
WHERE contact_client_id = $client_id
|
||||
AND (contact_important = 1
|
||||
OR contact_billing = 1
|
||||
@@ -25,7 +27,7 @@ $sql_important_contacts = mysqli_query(
|
||||
|
||||
$sql_favorite_assets = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT * FROM assets
|
||||
"SELECT asset_id, asset_make, asset_model, asset_name, asset_type FROM assets
|
||||
WHERE asset_client_id = $client_id
|
||||
AND asset_favorite = 1
|
||||
AND asset_archived_at IS NULL
|
||||
@@ -34,7 +36,8 @@ $sql_favorite_assets = mysqli_query(
|
||||
|
||||
$sql_favorite_credentials = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT * FROM credentials
|
||||
"SELECT credential_description, credential_id, credential_name, credential_otp_secret,
|
||||
credential_uri, credential_uri_2, credential_username FROM credentials
|
||||
WHERE credential_client_id = $client_id
|
||||
AND credential_favorite = 1
|
||||
AND credential_archived_at IS NULL
|
||||
@@ -74,7 +77,7 @@ $sql_shared_items = mysqli_query(
|
||||
// Stale Tickets
|
||||
$sql_stale_tickets = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT * FROM tickets
|
||||
"SELECT ticket_created_at, ticket_id, ticket_number, ticket_prefix, ticket_subject FROM tickets
|
||||
WHERE ticket_client_id = $client_id
|
||||
AND ticket_updated_at < CURRENT_DATE - INTERVAL 7 DAY
|
||||
AND ticket_resolved_At IS NULL
|
||||
@@ -87,7 +90,7 @@ $sql_stale_tickets = mysqli_query(
|
||||
// Get Domains Expiring
|
||||
$sql_domains_expiring = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT * FROM domains
|
||||
"SELECT domain_expire, domain_id, domain_name FROM domains
|
||||
WHERE domain_client_id = $client_id
|
||||
AND domain_expire IS NOT NULL
|
||||
AND domain_archived_at IS NULL
|
||||
@@ -99,7 +102,7 @@ $sql_domains_expiring = mysqli_query(
|
||||
// Get Certificates Expiring
|
||||
$sql_certificates_expiring = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT * FROM certificates
|
||||
"SELECT certificate_expire, certificate_id, certificate_name FROM certificates
|
||||
WHERE certificate_client_id = $client_id
|
||||
AND certificate_expire IS NOT NULL
|
||||
AND certificate_archived_at IS NULL
|
||||
@@ -111,7 +114,7 @@ $sql_certificates_expiring = mysqli_query(
|
||||
// Get Licenses Expiring
|
||||
$sql_licenses_expiring = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT * FROM software
|
||||
"SELECT software_expire, software_id, software_name FROM software
|
||||
WHERE software_client_id = $client_id
|
||||
AND software_expire IS NOT NULL
|
||||
AND software_archived_at IS NULL
|
||||
@@ -123,7 +126,7 @@ $sql_licenses_expiring = mysqli_query(
|
||||
// Get Asset Warranties Expiring
|
||||
$sql_asset_warranties_expiring = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT * FROM assets
|
||||
"SELECT asset_id, asset_name, asset_warranty_expire FROM assets
|
||||
WHERE asset_client_id = $client_id
|
||||
AND asset_warranty_expire IS NOT NULL
|
||||
AND asset_archived_at IS NULL
|
||||
@@ -135,7 +138,7 @@ $sql_asset_warranties_expiring = mysqli_query(
|
||||
// Get Assets Retiring 7 Year
|
||||
$sql_asset_retire = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT * FROM assets
|
||||
"SELECT asset_id, asset_install_date, asset_name FROM assets
|
||||
WHERE asset_client_id = $client_id
|
||||
AND asset_install_date IS NOT NULL
|
||||
AND asset_archived_at IS NULL
|
||||
@@ -151,7 +154,7 @@ $sql_asset_retire = mysqli_query(
|
||||
// Get Domains Expired
|
||||
$sql_domains_expired = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT * FROM domains
|
||||
"SELECT domain_expire, domain_id, domain_name FROM domains
|
||||
WHERE domain_client_id = $client_id
|
||||
AND domain_expire IS NOT NULL
|
||||
AND domain_archived_at IS NULL
|
||||
@@ -162,7 +165,7 @@ $sql_domains_expired = mysqli_query(
|
||||
// Get Certificates Expired
|
||||
$sql_certificates_expired = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT * FROM certificates
|
||||
"SELECT certificate_expire, certificate_id, certificate_name FROM certificates
|
||||
WHERE certificate_client_id = $client_id
|
||||
AND certificate_expire IS NOT NULL
|
||||
AND certificate_archived_at IS NULL
|
||||
@@ -173,7 +176,7 @@ $sql_certificates_expired = mysqli_query(
|
||||
// Get Licenses Expired
|
||||
$sql_licenses_expired = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT * FROM software
|
||||
"SELECT software_expire, software_id, software_name FROM software
|
||||
WHERE software_client_id = $client_id
|
||||
AND software_expire IS NOT NULL
|
||||
AND software_archived_at IS NULL
|
||||
@@ -184,7 +187,7 @@ $sql_licenses_expired = mysqli_query(
|
||||
// Get Asset Warranties Expired
|
||||
$sql_asset_warranties_expired = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT * FROM assets
|
||||
"SELECT asset_id, asset_name, asset_warranty_expire FROM assets
|
||||
WHERE asset_client_id = $client_id
|
||||
AND asset_warranty_expire IS NOT NULL
|
||||
AND asset_archived_at IS NULL
|
||||
@@ -195,7 +198,7 @@ $sql_asset_warranties_expired = mysqli_query(
|
||||
// Get Retired Assets
|
||||
$sql_asset_retired = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT * FROM assets
|
||||
"SELECT asset_id, asset_install_date, asset_name FROM assets
|
||||
WHERE asset_client_id = $client_id
|
||||
AND asset_install_date IS NOT NULL
|
||||
AND asset_archived_at IS NULL
|
||||
|
||||
@@ -64,7 +64,11 @@ if (isset($_GET['contact_id'])) {
|
||||
}
|
||||
|
||||
// Related Assets Query - 1 to 1 relationship
|
||||
$sql_related_assets = mysqli_query($mysqli, "SELECT * FROM assets
|
||||
$sql_related_assets = mysqli_query($mysqli, "SELECT asset_created_at, asset_description, asset_favorite, asset_id, asset_install_date,
|
||||
asset_make, asset_model, asset_name, asset_notes, asset_os, asset_photo,
|
||||
asset_physical_location, asset_purchase_date, asset_serial, asset_status, asset_type,
|
||||
asset_uri, asset_uri_2, asset_warranty_expire, interface_ip, interface_ipv6, interface_mac,
|
||||
interface_nat_ip, tag_color, tag_icon, tag_id, tag_name FROM assets
|
||||
LEFT JOIN asset_interfaces ON interface_asset_id = asset_id AND interface_primary = 1
|
||||
LEFT JOIN asset_tags ON asset_tag_asset_id = asset_id
|
||||
LEFT JOIN tags ON tag_id = asset_tag_tag_id
|
||||
@@ -102,14 +106,17 @@ if (isset($_GET['contact_id'])) {
|
||||
$credential_count = mysqli_num_rows($sql_related_credentials);
|
||||
|
||||
// Related Tickets Query - 1 to 1 relationship
|
||||
$sql_related_tickets = mysqli_query($mysqli, "SELECT * FROM tickets
|
||||
$sql_related_tickets = mysqli_query($mysqli, "SELECT ticket_assigned_to, ticket_closed_at, ticket_created_at, ticket_id, ticket_number,
|
||||
ticket_prefix, ticket_priority, ticket_status, ticket_status_color, ticket_status_name,
|
||||
ticket_subject, ticket_updated_at, user_name FROM tickets
|
||||
LEFT JOIN users ON ticket_assigned_to = user_id
|
||||
LEFT JOIN ticket_statuses ON ticket_status = ticket_status_id
|
||||
WHERE ticket_contact_id = $contact_id ORDER BY ticket_id DESC");
|
||||
$ticket_count = mysqli_num_rows($sql_related_tickets);
|
||||
|
||||
// Related Recurring Tickets Query
|
||||
$sql_related_recurring_tickets = mysqli_query($mysqli, "SELECT * FROM recurring_tickets
|
||||
$sql_related_recurring_tickets = mysqli_query($mysqli, "SELECT recurring_ticket_frequency, recurring_ticket_id, recurring_ticket_next_run,
|
||||
recurring_ticket_priority, recurring_ticket_subject FROM recurring_tickets
|
||||
WHERE recurring_ticket_contact_id = $contact_id
|
||||
ORDER BY recurring_ticket_next_run DESC"
|
||||
);
|
||||
@@ -139,7 +146,7 @@ if (isset($_GET['contact_id'])) {
|
||||
$contact_tags_display = implode('', $contact_tag_name_display_array);
|
||||
|
||||
// Notes - 1 to 1 relationship
|
||||
$sql_related_notes = mysqli_query($mysqli, "SELECT * FROM contact_notes LEFT JOIN users ON contact_note_created_by = user_id WHERE contact_note_contact_id = $contact_id AND contact_note_archived_at IS NULL ORDER BY contact_note_created_at DESC");
|
||||
$sql_related_notes = mysqli_query($mysqli, "SELECT contact_note, contact_note_created_at, contact_note_id, contact_note_type, user_name FROM contact_notes LEFT JOIN users ON contact_note_created_by = user_id WHERE contact_note_contact_id = $contact_id AND contact_note_archived_at IS NULL ORDER BY contact_note_created_at DESC");
|
||||
$note_count = mysqli_num_rows($sql_related_notes);
|
||||
|
||||
// Note type icons, read from the categories list so the seeded icons
|
||||
@@ -151,7 +158,8 @@ if (isset($_GET['contact_id'])) {
|
||||
}
|
||||
|
||||
// Linked Services
|
||||
$sql_linked_services = mysqli_query($mysqli, "SELECT * FROM service_contacts, services
|
||||
$sql_linked_services = mysqli_query($mysqli, "SELECT service_category, service_description, service_contacts.service_id, service_importance,
|
||||
service_name FROM service_contacts, services
|
||||
WHERE service_contacts.contact_id = $contact_id
|
||||
AND service_contacts.service_id = services.service_id
|
||||
ORDER BY service_name ASC"
|
||||
@@ -161,7 +169,8 @@ if (isset($_GET['contact_id'])) {
|
||||
$linked_services = array();
|
||||
|
||||
// Linked Documents
|
||||
$sql_linked_documents = mysqli_query($mysqli, "SELECT * FROM contact_documents, documents
|
||||
$sql_linked_documents = mysqli_query($mysqli, "SELECT document_created_at, document_description, documents.document_id, document_name,
|
||||
document_updated_at, user_name FROM contact_documents, documents
|
||||
LEFT JOIN users ON document_created_by = user_id
|
||||
WHERE contact_documents.contact_id = $contact_id
|
||||
AND contact_documents.document_id = documents.document_id
|
||||
|
||||
@@ -179,7 +179,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
||||
<option value="">- All Asset 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");
|
||||
$sql_locations_filter = mysqli_query($mysqli, "SELECT location_id, location_name FROM locations WHERE location_client_id = $client_id AND location_archived_at IS NULL ORDER BY location_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_locations_filter)) {
|
||||
$location_id = intval($row['location_id']);
|
||||
$location_name = escapeHtml($row['location_name']);
|
||||
|
||||
@@ -120,14 +120,14 @@ if ($user_config_dashboard_financial_enable == 1) {
|
||||
$sql_accounts = mysqli_query($mysqli, "SELECT * FROM accounts WHERE account_archived_at IS NULL ORDER BY account_name ASC");
|
||||
|
||||
$sql_latest_invoice_payments = mysqli_query($mysqli, "
|
||||
SELECT * FROM payments
|
||||
SELECT client_name, invoice_number, invoice_prefix, payment_amount, payment_date FROM payments
|
||||
JOIN invoices ON payment_invoice_id = invoice_id
|
||||
JOIN clients ON invoice_client_id = client_id
|
||||
ORDER BY payment_id DESC LIMIT 5
|
||||
");
|
||||
|
||||
$sql_latest_expenses = mysqli_query($mysqli, "
|
||||
SELECT * FROM expenses
|
||||
SELECT category_name, expense_amount, expense_date, vendor_name FROM expenses
|
||||
JOIN vendors ON expense_vendor_id = vendor_id
|
||||
JOIN categories ON expense_category_id = category_id
|
||||
ORDER BY expense_id DESC LIMIT 5
|
||||
@@ -599,7 +599,9 @@ if ($user_config_dashboard_technical_enable == 1) {
|
||||
$expiring_asset_warranties = $sql_asset_warranty_expiring['expiring_asset_warranties'];
|
||||
|
||||
$sql_your_tickets = mysqli_query($mysqli, "
|
||||
SELECT * FROM tickets
|
||||
SELECT client_name, contact_name, ticket_client_id, ticket_contact_id, ticket_created_at,
|
||||
ticket_id, ticket_number, ticket_prefix, ticket_priority, ticket_status,
|
||||
ticket_status_color, ticket_status_name, ticket_subject, ticket_updated_at FROM tickets
|
||||
LEFT JOIN ticket_statuses ON ticket_status = ticket_status_id
|
||||
LEFT JOIN clients ON ticket_client_id = client_id
|
||||
LEFT JOIN contacts ON ticket_contact_id = contact_id
|
||||
|
||||
@@ -142,7 +142,8 @@ $page_title = $row['document_name'];
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
$sql_document_versions = mysqli_query($mysqli, "SELECT * FROM document_versions
|
||||
$sql_document_versions = mysqli_query($mysqli, "SELECT document_version_created_at, document_version_description, document_version_id,
|
||||
document_version_name, user_name FROM document_versions
|
||||
LEFT JOIN users ON document_version_created_by = user_id
|
||||
WHERE document_version_document_id = $document_id
|
||||
ORDER BY document_version_created_at ASC"
|
||||
@@ -394,7 +395,8 @@ $page_title = $row['document_name'];
|
||||
<h6><i class="fas fa-history mr-2"></i>Revisions</h6>
|
||||
<?php
|
||||
|
||||
$sql_document_versions = mysqli_query($mysqli, "SELECT * FROM document_versions
|
||||
$sql_document_versions = mysqli_query($mysqli, "SELECT document_version_created_at, document_version_description, document_version_id,
|
||||
document_version_name, user_name FROM document_versions
|
||||
LEFT JOIN users ON document_version_created_by = user_id
|
||||
WHERE document_version_document_id = $document_id
|
||||
ORDER BY document_version_created_at DESC"
|
||||
|
||||
@@ -41,7 +41,10 @@ if (isset($_GET['category']) & !empty($_GET['category'])) {
|
||||
|
||||
$sql = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT SQL_CALC_FOUND_ROWS * FROM expenses
|
||||
"SELECT SQL_CALC_FOUND_ROWS account_name, category_name, client_name, expense_account_id, expense_amount,
|
||||
expense_category_id, expense_client_id, expense_created_at, expense_currency_code,
|
||||
expense_date, expense_description, expense_id, expense_receipt, expense_reference,
|
||||
expense_vendor_id, vendor_name FROM expenses
|
||||
LEFT JOIN categories ON expense_category_id = category_id
|
||||
LEFT JOIN vendors ON expense_vendor_id = vendor_id
|
||||
LEFT JOIN accounts ON expense_account_id = account_id
|
||||
|
||||
@@ -200,7 +200,7 @@
|
||||
<?php } ?>
|
||||
|
||||
<?php
|
||||
$sql_custom_links = mysqli_query($mysqli, "SELECT * FROM custom_links WHERE custom_link_location = 1 AND custom_link_archived_at IS NULL
|
||||
$sql_custom_links = mysqli_query($mysqli, "SELECT custom_link_icon, custom_link_name, custom_link_new_tab, custom_link_uri FROM custom_links WHERE custom_link_location = 1 AND custom_link_archived_at IS NULL
|
||||
ORDER BY custom_link_order ASC, custom_link_name ASC"
|
||||
);
|
||||
|
||||
|
||||
@@ -100,7 +100,8 @@ if (isset($_GET['invoice_id'])) {
|
||||
|
||||
$sql_history = mysqli_query($mysqli, "SELECT * FROM history WHERE history_invoice_id = $invoice_id ORDER BY history_id DESC");
|
||||
|
||||
$sql_payments = mysqli_query($mysqli, "SELECT * FROM payments, accounts WHERE payment_account_id = account_id AND payment_invoice_id = $invoice_id ORDER BY payments.payment_id DESC");
|
||||
$sql_payments = mysqli_query($mysqli, "SELECT account_name, payment_amount, payment_currency_code, payment_date, payment_id,
|
||||
payment_reference FROM payments, accounts WHERE payment_account_id = account_id AND payment_invoice_id = $invoice_id ORDER BY payments.payment_id DESC");
|
||||
|
||||
$sql_tickets = mysqli_query($mysqli, "
|
||||
SELECT
|
||||
@@ -372,7 +373,8 @@ if (isset($_GET['invoice_id'])) {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php $sql_invoice_items = mysqli_query($mysqli, "SELECT * FROM invoice_items WHERE item_invoice_id = $invoice_id ORDER BY item_order ASC"); ?>
|
||||
<?php $sql_invoice_items = mysqli_query($mysqli, "SELECT item_created_at, item_description, item_id, item_name, item_price, item_product_id,
|
||||
item_quantity, item_tax, item_tax_id, item_total FROM invoice_items WHERE item_invoice_id = $invoice_id ORDER BY item_order ASC"); ?>
|
||||
|
||||
<div class="row mb-3">
|
||||
<div class="col-md-12">
|
||||
|
||||
@@ -94,7 +94,11 @@ if (isset($_GET['category']) & !empty($_GET['category'])) {
|
||||
|
||||
$sql = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT SQL_CALC_FOUND_ROWS * FROM invoices
|
||||
"SELECT SQL_CALC_FOUND_ROWS category_id, category_name, client_currency_code, client_id, client_name, client_net_terms,
|
||||
invoice_amount, invoice_created_at, invoice_currency_code, invoice_date,
|
||||
invoice_discount_amount, invoice_due, invoice_id, invoice_number, invoice_prefix,
|
||||
invoice_scope, invoice_status, recurring_invoice_id, recurring_invoice_number,
|
||||
recurring_invoice_prefix FROM invoices
|
||||
LEFT JOIN clients ON invoice_client_id = client_id
|
||||
LEFT JOIN categories ON invoice_category_id = category_id
|
||||
LEFT JOIN recurring_invoices ON invoice_recurring_invoice_id = recurring_invoice_id
|
||||
|
||||
@@ -179,7 +179,8 @@ $sql_related_tickets = mysqli_query($mysqli, "
|
||||
$ticket_count = mysqli_num_rows($sql_related_tickets);
|
||||
|
||||
// Related Recurring Tickets Query
|
||||
$sql_related_recurring_tickets = mysqli_query($mysqli, "SELECT * FROM recurring_tickets
|
||||
$sql_related_recurring_tickets = mysqli_query($mysqli, "SELECT recurring_ticket_frequency, recurring_ticket_assets.recurring_ticket_id,
|
||||
recurring_ticket_next_run, recurring_ticket_priority, recurring_ticket_subject FROM recurring_tickets
|
||||
LEFT JOIN recurring_ticket_assets ON recurring_tickets.recurring_ticket_id = recurring_ticket_assets.recurring_ticket_id
|
||||
WHERE recurring_ticket_asset_id = $asset_id OR recurring_ticket_assets.asset_id = $asset_id
|
||||
GROUP BY recurring_tickets.recurring_ticket_id
|
||||
@@ -188,7 +189,8 @@ $sql_related_recurring_tickets = mysqli_query($mysqli, "SELECT * FROM recurring_
|
||||
$recurring_ticket_count = mysqli_num_rows($sql_related_recurring_tickets);
|
||||
|
||||
// Related Documents
|
||||
$sql_related_documents = mysqli_query($mysqli, "SELECT * FROM asset_documents
|
||||
$sql_related_documents = mysqli_query($mysqli, "SELECT document_created_at, document_description, documents.document_id, document_name,
|
||||
document_updated_at, user_name FROM asset_documents
|
||||
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
|
||||
@@ -219,7 +221,7 @@ $sql_related_software = mysqli_query(
|
||||
$software_count = mysqli_num_rows($sql_related_software);
|
||||
|
||||
// Related Notes
|
||||
$sql_related_notes = mysqli_query($mysqli, "SELECT * FROM asset_notes
|
||||
$sql_related_notes = mysqli_query($mysqli, "SELECT asset_note, asset_note_created_at, asset_note_type, user_name FROM asset_notes
|
||||
LEFT JOIN users ON asset_note_created_by = user_id
|
||||
WHERE asset_note_asset_id = $asset_id
|
||||
AND asset_note_archived_at IS NULL
|
||||
|
||||
@@ -7,10 +7,10 @@ $contact_id = intval($_GET['contact_id'] ?? 0);
|
||||
$type = escapeHtml(ucwords($_GET['type']) ?? '');
|
||||
|
||||
if ($client_id) {
|
||||
$sql_network_select = mysqli_query($mysqli, "SELECT * FROM networks WHERE network_archived_at IS NULL AND network_client_id = $client_id ORDER BY network_name ASC");
|
||||
$sql_vendor_select = mysqli_query($mysqli, "SELECT * FROM vendors WHERE vendor_archived_at IS NULL AND vendor_client_id = $client_id ORDER BY vendor_name ASC");
|
||||
$sql_network_select = mysqli_query($mysqli, "SELECT network, network_id, network_name FROM networks WHERE network_archived_at IS NULL AND network_client_id = $client_id ORDER BY network_name ASC");
|
||||
$sql_vendor_select = mysqli_query($mysqli, "SELECT vendor_id, vendor_name FROM vendors WHERE vendor_archived_at IS NULL AND vendor_client_id = $client_id ORDER BY vendor_name ASC");
|
||||
$sql_location_select = mysqli_query($mysqli, "SELECT location_id, location_name FROM locations WHERE location_archived_at IS NULL AND location_client_id = $client_id ORDER BY location_name ASC");
|
||||
$sql_contact_select = mysqli_query($mysqli, "SELECT * FROM contacts WHERE contact_archived_at IS NULL AND contact_client_id = $client_id ORDER BY contact_name ASC");
|
||||
$sql_contact_select = mysqli_query($mysqli, "SELECT contact_id, contact_name FROM contacts WHERE contact_archived_at IS NULL AND contact_client_id = $client_id ORDER BY contact_name ASC");
|
||||
} else {
|
||||
$sql_client_select = mysqli_query($mysqli, "SELECT client_id, client_name FROM clients WHERE client_archived_at IS NULL " . clientScopeSql('clients.client_id') . " ORDER BY client_name ASC");
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ ob_start();
|
||||
<option value="0">- None -</option>
|
||||
<?php
|
||||
|
||||
$sql_projects = mysqli_query($mysqli, "SELECT * FROM projects WHERE project_completed_at IS NULL AND project_archived_at IS NULL ORDER BY project_name ASC");
|
||||
$sql_projects = mysqli_query($mysqli, "SELECT project_id, project_name FROM projects WHERE project_completed_at IS NULL AND project_archived_at IS NULL ORDER BY project_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_projects)) {
|
||||
$project_id_select = intval($row['project_id']);
|
||||
$project_name_select = escapeHtml($row['project_name']); ?>
|
||||
|
||||
@@ -37,7 +37,7 @@ ob_start();
|
||||
<option value="">- Contact -</option>
|
||||
<?php
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM contacts WHERE contact_archived_at IS NULL AND contact_client_id = $client_id ORDER BY contact_name ASC");
|
||||
$sql = mysqli_query($mysqli, "SELECT contact_id, contact_name FROM contacts WHERE contact_archived_at IS NULL AND contact_client_id = $client_id ORDER BY contact_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql)) {
|
||||
$contact_id = intval($row['contact_id']);
|
||||
$contact_name = escapeHtml($row['contact_name']);
|
||||
|
||||
@@ -181,7 +181,7 @@ ob_start();
|
||||
<option value="">- Select Location -</option>
|
||||
<?php
|
||||
|
||||
$sql_locations = mysqli_query($mysqli, "SELECT * FROM locations WHERE location_archived_at IS NULL AND location_client_id = $client_id ORDER BY location_name ASC");
|
||||
$sql_locations = mysqli_query($mysqli, "SELECT location_id, location_name FROM locations WHERE location_archived_at IS NULL AND location_client_id = $client_id ORDER BY location_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_locations)) {
|
||||
$location_id_select = intval($row['location_id']);
|
||||
$location_name_select = escapeHtml($row['location_name']);
|
||||
@@ -213,7 +213,7 @@ ob_start();
|
||||
<option value="">- Select Contact -</option>
|
||||
<?php
|
||||
|
||||
$sql_contacts = mysqli_query($mysqli, "SELECT * FROM contacts WHERE contact_archived_at IS NULL AND contact_client_id = $client_id ORDER BY contact_name ASC");
|
||||
$sql_contacts = mysqli_query($mysqli, "SELECT contact_id, contact_name FROM contacts WHERE contact_archived_at IS NULL AND contact_client_id = $client_id ORDER BY contact_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_contacts)) {
|
||||
$contact_id_select = intval($row['contact_id']);
|
||||
$contact_name_select = escapeHtml($row['contact_name']);
|
||||
@@ -265,7 +265,7 @@ ob_start();
|
||||
<option value="">- Select Network -</option>
|
||||
<?php
|
||||
|
||||
$sql_networks = mysqli_query($mysqli, "SELECT * FROM networks WHERE network_archived_at IS NULL AND network_client_id = $client_id ORDER BY network_name ASC");
|
||||
$sql_networks = mysqli_query($mysqli, "SELECT network, network_id, network_name FROM networks WHERE network_archived_at IS NULL AND network_client_id = $client_id ORDER BY network_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_networks)) {
|
||||
$network_id_select = intval($row['network_id']);
|
||||
$network_name_select = escapeHtml($row['network_name']);
|
||||
@@ -358,7 +358,7 @@ ob_start();
|
||||
<option value="">- Select Vendor -</option>
|
||||
<?php
|
||||
|
||||
$sql_vendors = mysqli_query($mysqli, "SELECT * FROM vendors WHERE vendor_archived_at IS NULL AND vendor_client_id = $client_id ORDER BY vendor_name ASC");
|
||||
$sql_vendors = mysqli_query($mysqli, "SELECT vendor_id, vendor_name FROM vendors WHERE vendor_archived_at IS NULL AND vendor_client_id = $client_id ORDER BY vendor_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_vendors)) {
|
||||
$vendor_id_select = intval($row['vendor_id']);
|
||||
$vendor_name_select = escapeHtml($row['vendor_name']);
|
||||
|
||||
@@ -210,7 +210,7 @@ ob_start();
|
||||
<option value="">- Select Location -</option>
|
||||
<?php
|
||||
|
||||
$sql_locations = mysqli_query($mysqli, "SELECT * FROM locations WHERE location_id = $asset_location_id OR location_archived_at IS NULL AND location_client_id = $client_id ORDER BY location_name ASC");
|
||||
$sql_locations = mysqli_query($mysqli, "SELECT location_archived_at, location_id, location_name FROM locations WHERE location_id = $asset_location_id OR location_archived_at IS NULL AND location_client_id = $client_id ORDER BY location_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_locations)) {
|
||||
$location_id_select = intval($row['location_id']);
|
||||
$location_name_select = escapeHtml($row['location_name']);
|
||||
@@ -248,7 +248,7 @@ ob_start();
|
||||
<option value="">- Select Contact -</option>
|
||||
<?php
|
||||
|
||||
$sql_contacts = mysqli_query($mysqli, "SELECT * FROM contacts WHERE contact_id = $asset_contact_id OR contact_archived_at IS NULL AND contact_client_id = $client_id ORDER BY contact_name ASC");
|
||||
$sql_contacts = mysqli_query($mysqli, "SELECT contact_archived_at, contact_id, contact_name FROM contacts WHERE contact_id = $asset_contact_id OR contact_archived_at IS NULL AND contact_client_id = $client_id ORDER BY contact_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_contacts)) {
|
||||
$contact_id_select = intval($row['contact_id']);
|
||||
$contact_name_select = escapeHtml($row['contact_name']);
|
||||
@@ -308,7 +308,7 @@ ob_start();
|
||||
<option value="">- Select Network -</option>
|
||||
<?php
|
||||
|
||||
$sql_networks = mysqli_query($mysqli, "SELECT * FROM networks WHERE network_id = $asset_network_id OR network_archived_at IS NULL AND network_client_id = $client_id ORDER BY network_name ASC");
|
||||
$sql_networks = mysqli_query($mysqli, "SELECT network, network_archived_at, network_id, network_name FROM networks WHERE network_id = $asset_network_id OR network_archived_at IS NULL AND network_client_id = $client_id ORDER BY network_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_networks)) {
|
||||
$network_id_select = intval($row['network_id']);
|
||||
$network_name_select = escapeHtml($row['network_name']);
|
||||
@@ -416,7 +416,7 @@ ob_start();
|
||||
<option value="">- Select Vendor -</option>
|
||||
<?php
|
||||
|
||||
$sql_vendors = mysqli_query($mysqli, "SELECT * FROM vendors WHERE vendor_id = $asset_vendor_id OR vendor_archived_at IS NULL AND vendor_client_id = $client_id ORDER BY vendor_name ASC");
|
||||
$sql_vendors = mysqli_query($mysqli, "SELECT vendor_archived_at, vendor_id, vendor_name FROM vendors WHERE vendor_id = $asset_vendor_id OR vendor_archived_at IS NULL AND vendor_client_id = $client_id ORDER BY vendor_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_vendors)) {
|
||||
$vendor_id_select = intval($row['vendor_id']);
|
||||
$vendor_name_select = escapeHtml($row['vendor_name']);
|
||||
|
||||
@@ -111,7 +111,7 @@ ob_start();
|
||||
<select class="form-control select2" name="network">
|
||||
<option value="">- Select Network -</option>
|
||||
<?php
|
||||
$sql_network_select = mysqli_query($mysqli, "SELECT * FROM networks WHERE network_archived_at IS NULL AND network_client_id = $client_id ORDER BY network_name ASC");
|
||||
$sql_network_select = mysqli_query($mysqli, "SELECT network, network_id, network_name FROM networks WHERE network_archived_at IS NULL AND network_client_id = $client_id ORDER BY network_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_network_select)) {
|
||||
$network_id = $row['network_id'];
|
||||
$network_name = escapeHtml($row['network_name']);
|
||||
|
||||
@@ -167,7 +167,7 @@
|
||||
<option value="">- Client -</option>
|
||||
<?php
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM clients LEFT JOIN contacts ON clients.client_id = contacts.contact_client_id AND contact_primary = 1 ORDER BY client_name ASC");
|
||||
$sql = mysqli_query($mysqli, "SELECT client_id, client_name, contact_email FROM clients LEFT JOIN contacts ON clients.client_id = contacts.contact_client_id AND contact_primary = 1 ORDER BY client_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql)) {
|
||||
$client_id = intval($row['client_id']);
|
||||
$client_name = escapeHtml($row['client_name']);
|
||||
|
||||
@@ -212,7 +212,7 @@ ob_start();
|
||||
<option value="">- Client -</option>
|
||||
<?php
|
||||
|
||||
$sql_clients = mysqli_query($mysqli, "SELECT * FROM clients LEFT JOIN contacts ON clients.client_id = contacts.contact_client_id AND contact_primary = 1 ORDER BY client_name ASC");
|
||||
$sql_clients = mysqli_query($mysqli, "SELECT client_id, client_name, contact_email FROM clients LEFT JOIN contacts ON clients.client_id = contacts.contact_client_id AND contact_primary = 1 ORDER BY client_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_clients)) {
|
||||
$client_id_select = intval($row['client_id']);
|
||||
$client_name_select = escapeHtml($row['client_name']);
|
||||
|
||||
@@ -93,7 +93,7 @@ ob_start();
|
||||
<select class="form-control select2" name="domain_id">
|
||||
<option value="">- Domain -</option>
|
||||
<?php
|
||||
$domains_sql = mysqli_query($mysqli, "SELECT * FROM domains WHERE domain_archived_at IS NULL AND domain_client_id = $client_id ORDER BY domain_name ASC");
|
||||
$domains_sql = mysqli_query($mysqli, "SELECT domain_id, domain_name FROM domains WHERE domain_archived_at IS NULL AND domain_client_id = $client_id ORDER BY domain_name ASC");
|
||||
while ($domain_row = mysqli_fetch_assoc($domains_sql)) {
|
||||
$domain_id = intval($domain_row['domain_id']);
|
||||
$domain_name = escapeHtml($domain_row['domain_name']);
|
||||
|
||||
@@ -20,7 +20,8 @@ $certificate_expire = escapeHtml($row['certificate_expire']);
|
||||
$certificate_created_at = escapeHtml($row['certificate_created_at']);
|
||||
$client_id = intval($row['certificate_client_id']);
|
||||
|
||||
$history_sql = mysqli_query($mysqli, "SELECT * FROM certificate_history WHERE certificate_history_certificate_id = $certificate_id");
|
||||
$history_sql = mysqli_query($mysqli, "SELECT certificate_history_column, certificate_history_modified_at, certificate_history_new_value,
|
||||
certificate_history_old_value FROM certificate_history WHERE certificate_history_certificate_id = $certificate_id");
|
||||
|
||||
enforceClientAccess();
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ ob_start();
|
||||
<option value="0">- None -</option>
|
||||
<?php
|
||||
|
||||
$sql_projects = mysqli_query($mysqli, "SELECT * FROM projects WHERE project_completed_at IS NULL AND project_archived_at IS NULL ORDER BY project_name ASC");
|
||||
$sql_projects = mysqli_query($mysqli, "SELECT project_id, project_name FROM projects WHERE project_completed_at IS NULL AND project_archived_at IS NULL ORDER BY project_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_projects)) {
|
||||
$project_id_select = intval($row['project_id']);
|
||||
$project_name_select = escapeHtml($row['project_name']); ?>
|
||||
|
||||
@@ -52,7 +52,8 @@ $auth_method = escapeHtml($row['user_auth_method']);
|
||||
$contact_client_id = intval($row['contact_client_id']);
|
||||
|
||||
// Related Assets Query - 1 to 1 relationship
|
||||
$sql_related_assets = mysqli_query($mysqli, "SELECT * FROM assets
|
||||
$sql_related_assets = mysqli_query($mysqli, "SELECT asset_description, asset_favorite, asset_id, asset_install_date, asset_make, asset_model,
|
||||
asset_name, asset_serial, asset_status, asset_type FROM assets
|
||||
LEFT JOIN asset_interfaces ON interface_asset_id = asset_id AND interface_primary = 1
|
||||
LEFT JOIN asset_tags ON asset_tag_asset_id = asset_id
|
||||
LEFT JOIN tags ON tag_id = asset_tag_tag_id
|
||||
@@ -63,7 +64,8 @@ $sql_related_assets = mysqli_query($mysqli, "SELECT * FROM assets
|
||||
$asset_count = mysqli_num_rows($sql_related_assets);
|
||||
|
||||
// Linked Software Licenses
|
||||
$sql_linked_software = mysqli_query($mysqli, "SELECT * FROM software_contacts, software
|
||||
$sql_linked_software = mysqli_query($mysqli, "SELECT software.software_id, software_key, software_name, software_seats, software_type,
|
||||
software_version FROM software_contacts, software
|
||||
WHERE software_contacts.contact_id = $contact_id
|
||||
AND software_contacts.software_id = software.software_id
|
||||
AND software_archived_at IS NULL
|
||||
@@ -89,7 +91,9 @@ $sql_related_credentials = mysqli_query($mysqli, "
|
||||
$credential_count = mysqli_num_rows($sql_related_credentials);
|
||||
|
||||
// Related Tickets Query - 1 to 1 relationship
|
||||
$sql_related_tickets = mysqli_query($mysqli, "SELECT * FROM tickets
|
||||
$sql_related_tickets = mysqli_query($mysqli, "SELECT ticket_assigned_to, ticket_created_at, ticket_id, ticket_number, ticket_prefix,
|
||||
ticket_priority, ticket_status, ticket_status_color, ticket_status_name, ticket_subject,
|
||||
ticket_updated_at, user_name FROM tickets
|
||||
LEFT JOIN users ON ticket_assigned_to = user_id
|
||||
LEFT JOIN ticket_statuses ON ticket_status = ticket_status_id
|
||||
WHERE ticket_contact_id = $contact_id
|
||||
@@ -98,7 +102,8 @@ $sql_related_tickets = mysqli_query($mysqli, "SELECT * FROM tickets
|
||||
$ticket_count = mysqli_num_rows($sql_related_tickets);
|
||||
|
||||
// Related Recurring Tickets Query
|
||||
$sql_related_recurring_tickets = mysqli_query($mysqli, "SELECT * FROM recurring_tickets
|
||||
$sql_related_recurring_tickets = mysqli_query($mysqli, "SELECT recurring_ticket_frequency, recurring_ticket_next_run, recurring_ticket_priority,
|
||||
recurring_ticket_subject FROM recurring_tickets
|
||||
WHERE recurring_ticket_contact_id = $contact_id
|
||||
ORDER BY recurring_ticket_next_run DESC"
|
||||
);
|
||||
@@ -131,7 +136,7 @@ while ($row = mysqli_fetch_assoc($sql_contact_tags)) {
|
||||
$contact_tags_display = implode('', $contact_tag_name_display_array);
|
||||
|
||||
// Notes - 1 to 1 relationship
|
||||
$sql_related_notes = mysqli_query($mysqli, "SELECT * FROM contact_notes
|
||||
$sql_related_notes = mysqli_query($mysqli, "SELECT contact_note, contact_note_created_at, contact_note_type, user_name FROM contact_notes
|
||||
LEFT JOIN users ON contact_note_created_by = user_id
|
||||
WHERE contact_note_contact_id = $contact_id
|
||||
AND contact_note_archived_at IS NULL
|
||||
@@ -156,7 +161,8 @@ $services_count = mysqli_num_rows($sql_linked_services);
|
||||
$linked_services = array();
|
||||
|
||||
// Linked Documents
|
||||
$sql_linked_documents = mysqli_query($mysqli, "SELECT * FROM contact_documents, documents
|
||||
$sql_linked_documents = mysqli_query($mysqli, "SELECT document_created_at, document_description, documents.document_id, document_name,
|
||||
document_updated_at, user_name FROM contact_documents, documents
|
||||
LEFT JOIN users ON document_created_by = user_id
|
||||
WHERE contact_documents.contact_id = $contact_id
|
||||
AND contact_documents.document_id = documents.document_id
|
||||
|
||||
@@ -174,7 +174,7 @@ ob_start();
|
||||
<option value="">- Select Location -</option>
|
||||
<?php
|
||||
|
||||
$sql_locations = mysqli_query($mysqli, "SELECT * FROM locations WHERE location_id = $contact_location_id OR location_archived_at IS NULL AND location_client_id = $client_id ORDER BY location_name ASC");
|
||||
$sql_locations = mysqli_query($mysqli, "SELECT location_archived_at, location_id, location_name FROM locations WHERE location_id = $contact_location_id OR location_archived_at IS NULL AND location_client_id = $client_id ORDER BY location_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_locations)) {
|
||||
$location_id_select = intval($row['location_id']);
|
||||
$location_name_select = escapeHtml($row['location_name']);
|
||||
|
||||
@@ -167,7 +167,7 @@ ob_start();
|
||||
<option value="">- Select Contact -</option>
|
||||
<?php
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM contacts WHERE contact_client_id = $client_id ORDER BY contact_name ASC");
|
||||
$sql = mysqli_query($mysqli, "SELECT contact_id, contact_name FROM contacts WHERE contact_client_id = $client_id ORDER BY contact_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql)) {
|
||||
$contact_id_select = intval($row['contact_id']);
|
||||
$contact_name = escapeHtml($row['contact_name']);
|
||||
@@ -194,7 +194,7 @@ ob_start();
|
||||
<option value="">- Select Asset -</option>
|
||||
<?php
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT * 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 = 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");
|
||||
while ($row = mysqli_fetch_assoc($sql)) {
|
||||
$asset_id_select = intval($row['asset_id']);
|
||||
$asset_name = escapeHtml($row['asset_name']);
|
||||
|
||||
@@ -35,7 +35,7 @@ ob_start();
|
||||
<select class="form-control" name="document_template_id" required>
|
||||
<option value="">- Select Template -</option>
|
||||
<?php
|
||||
$sql_document_templates = mysqli_query($mysqli, "SELECT * FROM document_templates WHERE document_template_archived_at IS NULL ORDER BY document_template_name ASC");
|
||||
$sql_document_templates = mysqli_query($mysqli, "SELECT document_template_id, document_template_name FROM document_templates WHERE document_template_archived_at IS NULL ORDER BY document_template_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_document_templates)) {
|
||||
$document_template_id = intval($row['document_template_id']);
|
||||
$document_template_name = escapeHtml($row['document_template_name']);
|
||||
|
||||
@@ -95,7 +95,7 @@ ob_start();
|
||||
<option value="">- Vendor -</option>
|
||||
<?php
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM vendors WHERE vendor_archived_at IS NULL AND vendor_client_id = $client_id ORDER BY vendor_name ASC");
|
||||
$sql = mysqli_query($mysqli, "SELECT vendor_id, vendor_name FROM vendors WHERE vendor_archived_at IS NULL AND vendor_client_id = $client_id ORDER BY vendor_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql)) {
|
||||
$vendor_id = intval($row['vendor_id']);
|
||||
$vendor_name = escapeHtml($row['vendor_name']);
|
||||
@@ -116,7 +116,7 @@ ob_start();
|
||||
<option value="">- Vendor -</option>
|
||||
<?php
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM vendors WHERE vendor_archived_at IS NULL AND vendor_client_id = $client_id ORDER BY vendor_name ASC");
|
||||
$sql = mysqli_query($mysqli, "SELECT vendor_id, vendor_name FROM vendors WHERE vendor_archived_at IS NULL AND vendor_client_id = $client_id ORDER BY vendor_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql)) {
|
||||
$vendor_id = intval($row['vendor_id']);
|
||||
$vendor_name = escapeHtml($row['vendor_name']);
|
||||
@@ -137,7 +137,7 @@ ob_start();
|
||||
<option value="">- Vendor -</option>
|
||||
<?php
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM vendors WHERE vendor_archived_at IS NULL AND vendor_client_id = $client_id ORDER BY vendor_name ASC");
|
||||
$sql = mysqli_query($mysqli, "SELECT vendor_id, vendor_name FROM vendors WHERE vendor_archived_at IS NULL AND vendor_client_id = $client_id ORDER BY vendor_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql)) {
|
||||
$vendor_id = intval($row['vendor_id']);
|
||||
$vendor_name = escapeHtml($row['vendor_name']);
|
||||
@@ -158,7 +158,7 @@ ob_start();
|
||||
<option value="">- Vendor -</option>
|
||||
<?php
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM vendors WHERE vendor_archived_at IS NULL AND vendor_client_id = $client_id ORDER BY vendor_name ASC");
|
||||
$sql = mysqli_query($mysqli, "SELECT vendor_id, vendor_name FROM vendors WHERE vendor_archived_at IS NULL AND vendor_client_id = $client_id ORDER BY vendor_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql)) {
|
||||
$vendor_id = intval($row['vendor_id']);
|
||||
$vendor_name = escapeHtml($row['vendor_name']);
|
||||
|
||||
@@ -26,7 +26,8 @@ $domain_created_at = escapeHtml($row['domain_created_at']);
|
||||
$domain_archived_at = escapeHtml($row['domain_archived_at']);
|
||||
$client_id = intval($row['domain_client_id']);
|
||||
|
||||
$history_sql = mysqli_query($mysqli, "SELECT * FROM domain_history WHERE domain_history_domain_id = $domain_id");
|
||||
$history_sql = mysqli_query($mysqli, "SELECT domain_history_column, domain_history_modified_at, domain_history_new_value,
|
||||
domain_history_old_value FROM domain_history WHERE domain_history_domain_id = $domain_id");
|
||||
|
||||
enforceClientAccess();
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
<option value="">- Select an Asset -</option>
|
||||
<?php
|
||||
|
||||
$sql_assets_select = mysqli_query($mysqli, "SELECT * FROM assets
|
||||
$sql_assets_select = mysqli_query($mysqli, "SELECT asset_id, asset_name FROM assets
|
||||
WHERE asset_client_id = $client_id
|
||||
AND asset_archived_at IS NULL
|
||||
ORDER BY asset_name ASC"
|
||||
@@ -40,7 +40,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
$sql_assets = mysqli_query($mysqli, "SELECT * FROM assets, asset_files
|
||||
$sql_assets = mysqli_query($mysqli, "SELECT assets.asset_id, asset_name FROM assets, asset_files
|
||||
WHERE assets.asset_id = asset_files.asset_id
|
||||
AND asset_files.file_id = $file_id
|
||||
ORDER BY asset_name ASC"
|
||||
|
||||
@@ -32,7 +32,7 @@ ob_start();
|
||||
<option value="">- Select a Client -</option>
|
||||
<?php
|
||||
//select unarchived clients
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM clients WHERE client_archived_at IS NULL " . clientScopeSql('clients.client_id') . " ORDER BY client_name ASC");
|
||||
$sql = mysqli_query($mysqli, "SELECT client_id, client_name FROM clients WHERE client_archived_at IS NULL " . clientScopeSql('clients.client_id') . " ORDER BY client_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql)) {
|
||||
$client_id_select = intval($row['client_id']);
|
||||
$client_name = escapeHtml($row['client_name']);
|
||||
|
||||
@@ -21,7 +21,8 @@ $invoice_badge_color = getInvoiceBadgeColor($invoice_status);
|
||||
|
||||
$sql_payments = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT * FROM payments
|
||||
"SELECT account_archived_at, account_name, payment_amount, payment_currency_code, payment_date,
|
||||
payment_id, payment_method, payment_reference FROM payments
|
||||
LEFT JOIN accounts ON payment_account_id = account_id
|
||||
WHERE payment_invoice_id = $invoice_id
|
||||
AND payment_archived_at IS NULL
|
||||
|
||||
@@ -171,7 +171,7 @@ ob_start();
|
||||
<option value="">- Contact -</option>
|
||||
<?php
|
||||
|
||||
$sql_contacts = mysqli_query($mysqli, "SELECT * FROM contacts WHERE contact_archived_at IS NULL AND contact_client_id = $client_id ORDER BY contact_name ASC");
|
||||
$sql_contacts = mysqli_query($mysqli, "SELECT contact_id, contact_name FROM contacts WHERE contact_archived_at IS NULL AND contact_client_id = $client_id ORDER BY contact_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_contacts)) {
|
||||
$contact_id = $row['contact_id'];
|
||||
$contact_name = escapeHtml($row['contact_name']);
|
||||
|
||||
@@ -186,7 +186,7 @@ ob_start();
|
||||
<option value="">- Contact -</option>
|
||||
<?php
|
||||
|
||||
$sql_contacts = mysqli_query($mysqli, "SELECT * FROM contacts WHERE (contact_archived_at > '$location_created_at' OR contact_archived_at IS NULL) AND contact_client_id = $client_id ORDER BY contact_archived_at ASC, contact_name ASC");
|
||||
$sql_contacts = mysqli_query($mysqli, "SELECT contact_archived_at, contact_id, contact_name FROM contacts WHERE (contact_archived_at > '$location_created_at' OR contact_archived_at IS NULL) AND contact_client_id = $client_id ORDER BY contact_archived_at ASC, contact_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_contacts)) {
|
||||
$contact_id_select = intval($row['contact_id']);
|
||||
$contact_name_select = escapeHtml($row['contact_name']);
|
||||
|
||||
@@ -78,7 +78,7 @@ ob_start();
|
||||
<option value="">- Select Location -</option>
|
||||
<?php
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM locations WHERE location_archived_at IS NULL AND location_client_id = $client_id ORDER BY location_name ASC");
|
||||
$sql = mysqli_query($mysqli, "SELECT location_id, location_name FROM locations WHERE location_archived_at IS NULL AND location_client_id = $client_id ORDER BY location_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql)) {
|
||||
$location_id_select = intval($row['location_id']);
|
||||
$location_name = escapeHtml($row['location_name']);
|
||||
|
||||
@@ -30,7 +30,7 @@ ob_start();
|
||||
<select class="form-control select2" name="client_id">
|
||||
<option value="0">- No Client -</option>
|
||||
<?php
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM clients WHERE client_archived_at IS NULL " . clientScopeSql('clients.client_id') . " ORDER BY client_name ASC");
|
||||
$sql = mysqli_query($mysqli, "SELECT client_id, client_name FROM clients WHERE client_archived_at IS NULL " . clientScopeSql('clients.client_id') . " ORDER BY client_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql)) {
|
||||
$client_id_select = intval($row['client_id']);
|
||||
$client_name = escapeHtml($row['client_name']);
|
||||
@@ -61,7 +61,7 @@ ob_start();
|
||||
<select class="form-control select2" name="project_template_id">
|
||||
<option value="">- Template -</option>
|
||||
<?php
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM project_templates WHERE project_template_archived_at IS NULL ORDER BY project_template_name ASC");
|
||||
$sql = mysqli_query($mysqli, "SELECT project_template_id, project_template_name FROM project_templates WHERE project_template_archived_at IS NULL ORDER BY project_template_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql)) {
|
||||
$project_template_id = intval($row['project_template_id']);
|
||||
$project_template_name = escapeHtml($row['project_template_name']);
|
||||
|
||||
@@ -43,7 +43,7 @@ ob_start();
|
||||
<select class="form-control select2" data-placeholder="- Select Tickets- " multiple name="tickets[]" required>
|
||||
<?php
|
||||
|
||||
$sql_tickets_select = mysqli_query($mysqli, "SELECT * FROM tickets LEFT JOIN clients on ticket_client_id = client_id WHERE ticket_project_id = 0 AND ticket_closed_at IS NULL $client_ticket_select_query");
|
||||
$sql_tickets_select = mysqli_query($mysqli, "SELECT client_abbreviation, ticket_id, ticket_number, ticket_prefix, ticket_subject FROM tickets LEFT JOIN clients on ticket_client_id = client_id WHERE ticket_project_id = 0 AND ticket_closed_at IS NULL $client_ticket_select_query");
|
||||
while ($row = mysqli_fetch_assoc($sql_tickets_select)) {
|
||||
$ticket_id_select = intval($row['ticket_id']);
|
||||
$ticket_prefix_select = escapeHtml($row['ticket_prefix']);
|
||||
|
||||
@@ -33,7 +33,7 @@ ob_start();
|
||||
<?php
|
||||
|
||||
//select unarchived clients
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM clients WHERE client_archived_at IS NULL " . clientScopeSql('clients.client_id') . " ORDER BY client_name ASC");
|
||||
$sql = mysqli_query($mysqli, "SELECT client_id, client_name FROM clients WHERE client_archived_at IS NULL " . clientScopeSql('clients.client_id') . " ORDER BY client_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql)) {
|
||||
$client_id_select = intval($row['client_id']);
|
||||
$client_name = escapeHtml($row['client_name']);
|
||||
|
||||
@@ -41,7 +41,7 @@ ob_start();
|
||||
</div>
|
||||
<select class="form-control select2" name="client_id" required>
|
||||
<?php
|
||||
$sql_client_select = mysqli_query($mysqli, "SELECT * FROM clients WHERE client_archived_at IS NULL ORDER BY client_name ASC");
|
||||
$sql_client_select = mysqli_query($mysqli, "SELECT client_id, client_name FROM clients WHERE client_archived_at IS NULL ORDER BY client_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_client_select)) {
|
||||
$client_id_select = intval($row['client_id']);
|
||||
$client_name_select = escapeHtml($row['client_name']);
|
||||
|
||||
@@ -109,7 +109,7 @@ ob_start();
|
||||
<option value="">- Location -</option>
|
||||
<?php
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM locations WHERE location_archived_at IS NULL AND location_client_id = $client_id ORDER BY location_name ASC");
|
||||
$sql = mysqli_query($mysqli, "SELECT location_id, location_name FROM locations WHERE location_archived_at IS NULL AND location_client_id = $client_id ORDER BY location_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql)) {
|
||||
$location_id = intval($row['location_id']);
|
||||
$location_name = escapeHtml($row['location_name']);
|
||||
|
||||
@@ -58,7 +58,7 @@ ob_start();
|
||||
$assigned_assets_list = empty($assigned_assets_list) ? '0' : $assigned_assets_list;
|
||||
|
||||
// Fetch assets not assigned to any rack
|
||||
$sql_assets = mysqli_query($mysqli, "SELECT * FROM assets WHERE asset_archived_at IS NULL AND asset_client_id = $client_id AND asset_id NOT IN ($assigned_assets_list) ORDER BY asset_name ASC");
|
||||
$sql_assets = mysqli_query($mysqli, "SELECT asset_id, asset_name FROM assets WHERE asset_archived_at IS NULL AND asset_client_id = $client_id AND asset_id NOT IN ($assigned_assets_list) ORDER BY asset_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_assets)) {
|
||||
$asset_id = intval($row['asset_id']);
|
||||
$asset_name = escapeHtml($row['asset_name']);
|
||||
|
||||
@@ -132,7 +132,7 @@ ob_start();
|
||||
<option value="">- Location -</option>
|
||||
<?php
|
||||
|
||||
$sql_location_select = mysqli_query($mysqli, "SELECT * FROM locations WHERE location_archived_at IS NULL AND location_client_id = $client_id ORDER BY location_name ASC");
|
||||
$sql_location_select = mysqli_query($mysqli, "SELECT location_id, location_name FROM locations WHERE location_archived_at IS NULL AND location_client_id = $client_id ORDER BY location_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_location_select)) {
|
||||
$location_id_select = intval($row['location_id']);
|
||||
$location_name_select = escapeHtml($row['location_name']);
|
||||
|
||||
@@ -32,7 +32,7 @@ ob_start();
|
||||
<option value="">- Select a Client -</option>
|
||||
<?php
|
||||
//select unarchived clients
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM clients WHERE client_archived_at IS NULL " . clientScopeSql('clients.client_id') . " ORDER BY client_name ASC");
|
||||
$sql = mysqli_query($mysqli, "SELECT client_id, client_name FROM clients WHERE client_archived_at IS NULL " . clientScopeSql('clients.client_id') . " ORDER BY client_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql)) {
|
||||
$client_id = intval($row['client_id']);
|
||||
$client_name = escapeHtml($row['client_name']);
|
||||
|
||||
@@ -58,7 +58,7 @@ ob_start();
|
||||
<option value="">- Select a Client -</option>
|
||||
<?php
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM clients WHERE client_archived_at IS NULL " . clientScopeSql('clients.client_id') . " ORDER BY client_name ASC");
|
||||
$sql = mysqli_query($mysqli, "SELECT client_id, client_name FROM clients WHERE client_archived_at IS NULL " . clientScopeSql('clients.client_id') . " ORDER BY client_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql)) {
|
||||
$client_id_select = intval($row['client_id']);
|
||||
$client_name = escapeHtml($row['client_name']); ?>
|
||||
|
||||
@@ -55,7 +55,7 @@ $sql_credentials = mysqli_query(
|
||||
// Associated Domains
|
||||
$sql_domains = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT * FROM service_domains
|
||||
"SELECT domain_name FROM service_domains
|
||||
LEFT JOIN domains ON service_domains.domain_id = domains.domain_id
|
||||
WHERE service_id = $service_id"
|
||||
);
|
||||
@@ -63,7 +63,7 @@ $sql_domains = mysqli_query(
|
||||
// Associated Certificates
|
||||
$sql_certificates = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT * FROM service_certificates
|
||||
"SELECT certificate_domain, certificate_name FROM service_certificates
|
||||
LEFT JOIN certificates ON service_certificates.certificate_id = certificates.certificate_id
|
||||
WHERE service_id = $service_id"
|
||||
);
|
||||
@@ -71,7 +71,7 @@ $sql_certificates = mysqli_query(
|
||||
// Associated Vendors
|
||||
$sql_vendors = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT * FROM service_vendors
|
||||
"SELECT vendors.vendor_id, vendor_name FROM service_vendors
|
||||
LEFT JOIN vendors ON service_vendors.vendor_id = vendors.vendor_id
|
||||
WHERE service_id = $service_id"
|
||||
);
|
||||
@@ -79,7 +79,7 @@ $sql_vendors = mysqli_query(
|
||||
// Associated Contacts
|
||||
$sql_contacts = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT * FROM service_contacts
|
||||
"SELECT service_contacts.contact_id, contact_name FROM service_contacts
|
||||
LEFT JOIN contacts ON service_contacts.contact_id = contacts.contact_id
|
||||
WHERE service_id = $service_id"
|
||||
);
|
||||
@@ -87,7 +87,7 @@ $sql_contacts = mysqli_query(
|
||||
// Associated Documents
|
||||
$sql_docs = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT * FROM service_documents
|
||||
"SELECT documents.document_id, document_name FROM service_documents
|
||||
LEFT JOIN documents ON service_documents.document_id = documents.document_id
|
||||
WHERE service_id = $service_id"
|
||||
);
|
||||
|
||||
@@ -138,7 +138,7 @@ ob_start();
|
||||
<label for="contacts">Select related Contacts</label>
|
||||
<select class="form-control select2" id="contacts" name="contacts[]" multiple>
|
||||
<?php
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM contacts WHERE contact_archived_at IS NULL AND contact_client_id = $client_id");
|
||||
$sql = mysqli_query($mysqli, "SELECT contact_id, contact_name FROM contacts WHERE contact_archived_at IS NULL AND contact_client_id = $client_id");
|
||||
while ($row = mysqli_fetch_assoc($sql)) {
|
||||
$contact_id = intval($row['contact_id']);
|
||||
$contact_name = escapeHtml($row['contact_name']);
|
||||
@@ -152,7 +152,7 @@ ob_start();
|
||||
<label for="vendors">Select related vendors</label>
|
||||
<select class="form-control select2" id="vendors" name="vendors[]" multiple>
|
||||
<?php
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM vendors WHERE vendor_archived_at IS NULL AND vendor_client_id = $client_id");
|
||||
$sql = mysqli_query($mysqli, "SELECT vendor_id, vendor_name FROM vendors WHERE vendor_archived_at IS NULL AND vendor_client_id = $client_id");
|
||||
while ($row = mysqli_fetch_assoc($sql)) {
|
||||
$vendor_id = intval($row['vendor_id']);
|
||||
$vendor_name = escapeHtml($row['vendor_name']);
|
||||
@@ -166,7 +166,7 @@ ob_start();
|
||||
<label for="documents">Select related documents</label>
|
||||
<select class="form-control select2" id="documents" name="documents[]" multiple>
|
||||
<?php
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM documents WHERE document_archived_at IS NULL AND document_client_id = $client_id");
|
||||
$sql = mysqli_query($mysqli, "SELECT document_id, document_name FROM documents WHERE document_archived_at IS NULL AND document_client_id = $client_id");
|
||||
while ($row = mysqli_fetch_assoc($sql)) {
|
||||
$document_id = intval($row['document_id']);
|
||||
$document_name = escapeHtml($row['document_name']);
|
||||
@@ -186,7 +186,7 @@ ob_start();
|
||||
<label for="assets">Select related assets</label>
|
||||
<select class="form-control select2" id="assets" name="assets[]" multiple>
|
||||
<?php
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM assets WHERE asset_archived_at IS NULL AND asset_client_id = $client_id");
|
||||
$sql = mysqli_query($mysqli, "SELECT asset_id, asset_name FROM assets WHERE asset_archived_at IS NULL AND asset_client_id = $client_id");
|
||||
while ($row = mysqli_fetch_assoc($sql)) {
|
||||
$asset_id = intval($row['asset_id']);
|
||||
$asset_name = escapeHtml($row['asset_name']);
|
||||
@@ -200,7 +200,7 @@ ob_start();
|
||||
<label for="logins">Select related Credentials</label>
|
||||
<select class="form-control select2" id="credentials" name="credentials[]" multiple>
|
||||
<?php
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM credentials WHERE credential_archived_at IS NULL AND credential_client_id = $client_id");
|
||||
$sql = mysqli_query($mysqli, "SELECT credential_id, credential_name FROM credentials WHERE credential_archived_at IS NULL AND credential_client_id = $client_id");
|
||||
while ($row = mysqli_fetch_assoc($sql)) {
|
||||
$credential_id = intval($row['credential_id']);
|
||||
$credential_name = escapeHtml($row['credential_name']);
|
||||
@@ -214,7 +214,7 @@ ob_start();
|
||||
<label for="domains">Select related domains</label>
|
||||
<select class="form-control select2" id="domains" name="domains[]" multiple>
|
||||
<?php
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM domains WHERE domain_archived_at IS NULL AND domain_client_id = $client_id");
|
||||
$sql = mysqli_query($mysqli, "SELECT domain_id, domain_name FROM domains WHERE domain_archived_at IS NULL AND domain_client_id = $client_id");
|
||||
while ($row = mysqli_fetch_assoc($sql)) {
|
||||
$domain_id = intval($row['domain_id']);
|
||||
$domain_name = escapeHtml($row['domain_name']);
|
||||
@@ -228,7 +228,7 @@ ob_start();
|
||||
<label for="certificates">Select related certificates</label>
|
||||
<select class="form-control select2" id="certificates" name="certificates[]" multiple>
|
||||
<?php
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM certificates WHERE certificate_archived_at IS NULL AND certificate_client_id = $client_id");
|
||||
$sql = mysqli_query($mysqli, "SELECT certificate_domain, certificate_id, certificate_name FROM certificates WHERE certificate_archived_at IS NULL AND certificate_client_id = $client_id");
|
||||
while ($row = mysqli_fetch_assoc($sql)) {
|
||||
$cert_id = intval($row['certificate_id']);
|
||||
$cert_name = escapeHtml($row['certificate_name']);
|
||||
|
||||
@@ -193,7 +193,7 @@ ob_start();
|
||||
// Get all contacts
|
||||
// NOTE: These are called $sql_all and $row_all for a reason - anything overwriting $sql or $row will break the current while loop we are in from client_services.php
|
||||
|
||||
$sql_all = mysqli_query($mysqli, "SELECT * FROM contacts WHERE (contact_archived_at > '$service_created_at' OR contact_archived_at IS NULL) AND contact_client_id = $client_id");
|
||||
$sql_all = mysqli_query($mysqli, "SELECT contact_id, contact_name FROM contacts WHERE (contact_archived_at > '$service_created_at' OR contact_archived_at IS NULL) AND contact_client_id = $client_id");
|
||||
|
||||
while ($row_all = mysqli_fetch_assoc($sql_all)) {
|
||||
$contact_id = intval($row_all['contact_id']);
|
||||
@@ -216,7 +216,7 @@ ob_start();
|
||||
<?php
|
||||
$selected_ids = array_column(mysqli_fetch_all($sql_vendors, MYSQLI_ASSOC), "vendor_id");
|
||||
|
||||
$sql_all = mysqli_query($mysqli, "SELECT * FROM vendors WHERE (vendor_archived_at > '$service_created_at' OR vendor_archived_at IS NULL) AND vendor_client_id = $client_id");
|
||||
$sql_all = mysqli_query($mysqli, "SELECT vendor_id, vendor_name FROM vendors WHERE (vendor_archived_at > '$service_created_at' OR vendor_archived_at IS NULL) AND vendor_client_id = $client_id");
|
||||
while ($row_all = mysqli_fetch_assoc($sql_all)) {
|
||||
$vendor_id = intval($row_all['vendor_id']);
|
||||
$vendor_name = escapeHtml($row_all['vendor_name']);
|
||||
@@ -238,7 +238,7 @@ ob_start();
|
||||
<?php
|
||||
$selected_ids = array_column(mysqli_fetch_all($sql_docs, MYSQLI_ASSOC), "document_id");
|
||||
|
||||
$sql_all = mysqli_query($mysqli, "SELECT * FROM documents WHERE document_archived_at IS NULL AND document_client_id = $client_id");
|
||||
$sql_all = mysqli_query($mysqli, "SELECT document_id, document_name FROM documents WHERE document_archived_at IS NULL AND document_client_id = $client_id");
|
||||
while ($row_all = mysqli_fetch_assoc($sql_all)) {
|
||||
$document_id = intval($row_all['document_id']);
|
||||
$document_name = escapeHtml($row_all['document_name']);
|
||||
@@ -268,7 +268,7 @@ ob_start();
|
||||
<?php
|
||||
$selected_ids = array_column(mysqli_fetch_all($sql_assets, MYSQLI_ASSOC), "asset_id");
|
||||
|
||||
$sql_all = mysqli_query($mysqli, "SELECT * FROM assets WHERE (asset_archived_at > '$service_created_at' OR asset_archived_at IS NULL) AND asset_client_id = $client_id");
|
||||
$sql_all = mysqli_query($mysqli, "SELECT asset_id, asset_name FROM assets WHERE (asset_archived_at > '$service_created_at' OR asset_archived_at IS NULL) AND asset_client_id = $client_id");
|
||||
while ($row_all = mysqli_fetch_assoc($sql_all)) {
|
||||
$asset_id = intval($row_all['asset_id']);
|
||||
$asset_name = escapeHtml($row_all['asset_name']);
|
||||
@@ -290,7 +290,7 @@ ob_start();
|
||||
<?php
|
||||
$selected_ids = array_column(mysqli_fetch_all($sql_credentials, MYSQLI_ASSOC), "credential_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 credential_id, credential_name FROM credentials WHERE (credential_archived_at > '$service_created_at' OR credential_archived_at IS NULL) AND credential_client_id = $client_id");
|
||||
while ($row_all = mysqli_fetch_assoc($sql_all)) {
|
||||
$credential_id = intval($row_all['credential_id']);
|
||||
$credential_name = escapeHtml($row_all['credential_name']);
|
||||
@@ -312,7 +312,7 @@ ob_start();
|
||||
<?php
|
||||
$selected_ids = array_column(mysqli_fetch_all($sql_domains, MYSQLI_ASSOC), "domain_id");
|
||||
|
||||
$sql_all = mysqli_query($mysqli, "SELECT * FROM domains WHERE (domain_archived_at > '$service_created_at' OR domain_archived_at IS NULL) AND domain_client_id = $client_id");
|
||||
$sql_all = mysqli_query($mysqli, "SELECT domain_id, domain_name FROM domains WHERE (domain_archived_at > '$service_created_at' OR domain_archived_at IS NULL) AND domain_client_id = $client_id");
|
||||
while ($row_all = mysqli_fetch_assoc($sql_all)) {
|
||||
$domain_id = intval($row_all['domain_id']);
|
||||
$domain_name = escapeHtml($row_all['domain_name']);
|
||||
@@ -334,7 +334,7 @@ ob_start();
|
||||
<?php
|
||||
$selected_ids = array_column(mysqli_fetch_all($sql_certificates, MYSQLI_ASSOC), "certificate_id");
|
||||
|
||||
$sql_all = mysqli_query($mysqli, "SELECT * FROM certificates WHERE (certificate_archived_at > '$service_created_at' OR certificate_archived_at IS NULL) AND certificate_client_id = $client_id");
|
||||
$sql_all = mysqli_query($mysqli, "SELECT certificate_id, certificate_name FROM certificates WHERE (certificate_archived_at > '$service_created_at' OR certificate_archived_at IS NULL) AND certificate_client_id = $client_id");
|
||||
while ($row_all = mysqli_fetch_assoc($sql_all)) {
|
||||
$cert_id = intval($row_all['certificate_id']);
|
||||
$cert_name = escapeHtml($row_all['certificate_name']);
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
<option value=""></option>
|
||||
<?php
|
||||
|
||||
$sql_client_contacts_select = mysqli_query($mysqli, "SELECT * FROM contacts WHERE contact_client_id = $client_id AND contact_email <> '' AND contact_archived_at IS NULL ORDER BY contact_name ASC");
|
||||
$sql_client_contacts_select = mysqli_query($mysqli, "SELECT contact_email, contact_id, contact_name FROM contacts WHERE contact_client_id = $client_id AND contact_email <> '' AND contact_archived_at IS NULL ORDER BY contact_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_client_contacts_select)) {
|
||||
$contact_id_select = intval($row['contact_id']);
|
||||
$contact_name_select = escapeHtml($row['contact_name']);
|
||||
|
||||
@@ -244,7 +244,7 @@ ob_start();
|
||||
|
||||
|
||||
<?php
|
||||
$sql_assets_select = mysqli_query($mysqli, "SELECT * FROM assets LEFT JOIN contacts ON asset_contact_id = contact_id WHERE asset_archived_at IS NULL AND asset_client_id = $client_id ORDER BY asset_archived_at ASC, asset_name ASC");
|
||||
$sql_assets_select = mysqli_query($mysqli, "SELECT asset_archived_at, asset_id, asset_name, asset_type, contact_name FROM assets LEFT JOIN contacts ON asset_contact_id = contact_id WHERE asset_archived_at IS NULL AND asset_client_id = $client_id ORDER BY asset_archived_at ASC, asset_name ASC");
|
||||
|
||||
while ($row = mysqli_fetch_assoc($sql_assets_select)) {
|
||||
$asset_id_select = intval($row['asset_id']);
|
||||
@@ -284,7 +284,7 @@ ob_start();
|
||||
</li>
|
||||
|
||||
<?php
|
||||
$sql_contacts_select = mysqli_query($mysqli, "SELECT * FROM contacts WHERE contact_archived_at IS NULL AND contact_client_id = $client_id ORDER BY contact_name ASC");
|
||||
$sql_contacts_select = mysqli_query($mysqli, "SELECT contact_email, contact_id, contact_name FROM contacts WHERE contact_archived_at IS NULL AND contact_client_id = $client_id ORDER BY contact_name ASC");
|
||||
|
||||
while ($row = mysqli_fetch_assoc($sql_contacts_select)) {
|
||||
$contact_id_select = intval($row['contact_id']);
|
||||
|
||||
@@ -55,7 +55,7 @@ ob_start();
|
||||
<select class="form-control" name="software_template_id" required>
|
||||
<option value="">- Select Template -</option>
|
||||
<?php
|
||||
$sql_software_templates = mysqli_query($mysqli, "SELECT * FROM software_templates WHERE software_template_archived_at IS NULL ORDER BY software_template_name ASC");
|
||||
$sql_software_templates = mysqli_query($mysqli, "SELECT software_template_id, software_template_name FROM software_templates WHERE software_template_archived_at IS NULL ORDER BY software_template_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_software_templates)) {
|
||||
$software_template_id = intval($row['software_template_id']);
|
||||
$software_template_name = escapeHtml($row['software_template_name']);
|
||||
|
||||
@@ -258,7 +258,7 @@ ob_start();
|
||||
|
||||
|
||||
<?php
|
||||
$sql_assets_select = mysqli_query($mysqli, "SELECT * FROM assets LEFT JOIN contacts ON asset_contact_id = contact_id WHERE (asset_archived_at > '$software_created_at' OR asset_archived_at IS NULL) AND asset_client_id = $client_id ORDER BY asset_archived_at ASC, asset_name ASC");
|
||||
$sql_assets_select = mysqli_query($mysqli, "SELECT asset_archived_at, asset_id, asset_name, asset_type, contact_name FROM assets LEFT JOIN contacts ON asset_contact_id = contact_id WHERE (asset_archived_at > '$software_created_at' OR asset_archived_at IS NULL) AND asset_client_id = $client_id ORDER BY asset_archived_at ASC, asset_name ASC");
|
||||
|
||||
while ($row = mysqli_fetch_assoc($sql_assets_select)) {
|
||||
$asset_id_select = intval($row['asset_id']);
|
||||
@@ -298,7 +298,7 @@ ob_start();
|
||||
</li>
|
||||
|
||||
<?php
|
||||
$sql_contacts_select = mysqli_query($mysqli, "SELECT * FROM contacts WHERE (contact_archived_at > '$software_created_at' OR contact_archived_at IS NULL) AND contact_client_id = $client_id ORDER BY contact_archived_at ASC, contact_name ASC");
|
||||
$sql_contacts_select = mysqli_query($mysqli, "SELECT contact_archived_at, contact_email, contact_id, contact_name FROM contacts WHERE (contact_archived_at > '$software_created_at' OR contact_archived_at IS NULL) AND contact_client_id = $client_id ORDER BY contact_archived_at ASC, contact_name ASC");
|
||||
|
||||
while ($row = mysqli_fetch_assoc($sql_contacts_select)) {
|
||||
$contact_id_select = intval($row['contact_id']);
|
||||
|
||||
@@ -62,7 +62,7 @@ ob_start();
|
||||
<option value="">- Select a Client -</option>
|
||||
<?php
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM clients WHERE client_lead = 0 AND client_archived_at IS NULL " . clientScopeSql('clients.client_id') . " ORDER BY client_name ASC");
|
||||
$sql = mysqli_query($mysqli, "SELECT client_id, client_name FROM clients WHERE client_lead = 0 AND client_archived_at IS NULL " . clientScopeSql('clients.client_id') . " ORDER BY client_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql)) {
|
||||
$client_id_select = intval($row['client_id']);
|
||||
$client_name = escapeHtml($row['client_name']); ?>
|
||||
|
||||
@@ -12,7 +12,7 @@ if (!empty($ticket_ids)) {
|
||||
$whereNotIn = "AND ticket_id NOT IN ($ids)";
|
||||
}
|
||||
|
||||
$sql_merge = mysqli_query($mysqli, "SELECT * FROM tickets
|
||||
$sql_merge = mysqli_query($mysqli, "SELECT client_name, ticket_id, ticket_number, ticket_prefix, ticket_status_name, ticket_subject FROM tickets
|
||||
LEFT JOIN ticket_statuses ON ticket_status = ticket_status_id
|
||||
LEFT JOIN clients ON client_id = ticket_client_id
|
||||
WHERE ticket_closed_at IS NULL
|
||||
|
||||
@@ -81,7 +81,8 @@ $row = mysqli_fetch_assoc($ticket_total_reply_time);
|
||||
$ticket_total_reply_time = escapeHtml($row['ticket_total_reply_time']);
|
||||
$ticket_total_reply_time_display = formatDuration($ticket_total_reply_time);
|
||||
|
||||
$sql_invoices = mysqli_query($mysqli, "SELECT * FROM invoices WHERE invoice_status LIKE 'Draft' AND invoice_client_id = $client_id ORDER BY invoice_number ASC");
|
||||
$sql_invoices = mysqli_query($mysqli, "SELECT invoice_amount, invoice_date, invoice_due, invoice_id, invoice_number, invoice_prefix,
|
||||
invoice_scope, invoice_status FROM invoices WHERE invoice_status LIKE 'Draft' AND invoice_client_id = $client_id ORDER BY invoice_number ASC");
|
||||
|
||||
ob_start();
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ if ($client_id) {
|
||||
enforceClientAccess();
|
||||
}
|
||||
|
||||
$sql_merge = mysqli_query($mysqli, "SELECT * FROM tickets
|
||||
$sql_merge = mysqli_query($mysqli, "SELECT client_name, ticket_id, ticket_number, ticket_prefix, ticket_status_name, ticket_subject FROM tickets
|
||||
LEFT JOIN ticket_statuses ON ticket_status = ticket_status_id
|
||||
LEFT JOIN clients ON client_id = ticket_client_id
|
||||
WHERE ticket_closed_at IS NULL
|
||||
|
||||
@@ -100,7 +100,7 @@ ob_start();
|
||||
<option value="">- Select an Account -</option>
|
||||
|
||||
<?php
|
||||
$sql_accounts_filter = mysqli_query($mysqli, "SELECT * FROM accounts WHERE account_archived_at IS NULL ORDER BY account_name ASC");
|
||||
$sql_accounts_filter = mysqli_query($mysqli, "SELECT account_id, account_name FROM accounts WHERE account_archived_at IS NULL ORDER BY account_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_accounts_filter)) {
|
||||
$account_id = intval($row['account_id']);
|
||||
$account_name = escapeHtml($row['account_name']);
|
||||
|
||||
@@ -32,7 +32,7 @@ ob_start();
|
||||
<option value="0">- Client (Optional) -</option>
|
||||
<?php
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM clients WHERE client_archived_at is NULL " . clientScopeSql('clients.client_id') . " ORDER BY client_name ASC");
|
||||
$sql = mysqli_query($mysqli, "SELECT client_id, client_name FROM clients WHERE client_archived_at is NULL " . clientScopeSql('clients.client_id') . " ORDER BY client_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql)) {
|
||||
$client_id_select = intval($row['client_id']);
|
||||
$client_name = escapeHtml($row['client_name']);
|
||||
@@ -94,7 +94,7 @@ ob_start();
|
||||
<option value=""></option>
|
||||
<?php
|
||||
if ($client_id) {
|
||||
$sql_locations = mysqli_query($mysqli, "SELECT * FROM locations WHERE location_archived_at IS NULL AND location_client_id = $client_id ORDER BY location_name ASC");
|
||||
$sql_locations = mysqli_query($mysqli, "SELECT location_address, location_city, location_name, location_state, location_zip FROM locations WHERE location_archived_at IS NULL AND location_client_id = $client_id ORDER BY location_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_locations)) {
|
||||
$location_name = escapeHtml($row['location_name']);
|
||||
$location_address = escapeHtml($row['location_address']);
|
||||
|
||||
@@ -87,7 +87,7 @@ ob_start();
|
||||
<option><?= $trip_destination ?></option>
|
||||
<?php
|
||||
|
||||
$sql_locations_select = mysqli_query($mysqli, "SELECT * FROM locations WHERE location_archived_at IS NULL AND location_client_id = $client_id ORDER BY location_name ASC");
|
||||
$sql_locations_select = mysqli_query($mysqli, "SELECT location_address, location_city, location_name, location_state, location_zip FROM locations WHERE location_archived_at IS NULL AND location_client_id = $client_id ORDER BY location_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_locations_select)) {
|
||||
$location_name = escapeHtml($row['location_name']);
|
||||
$location_address = escapeHtml($row['location_address']);
|
||||
@@ -150,7 +150,7 @@ ob_start();
|
||||
<option value="">- Client (Optional) -</option>
|
||||
<?php
|
||||
|
||||
$sql_clients = mysqli_query($mysqli, "SELECT * FROM clients WHERE client_archived_at IS NULL " . clientScopeSql('clients.client_id') . " ORDER BY client_name ASC");
|
||||
$sql_clients = mysqli_query($mysqli, "SELECT client_id, client_name FROM clients WHERE client_archived_at IS NULL " . clientScopeSql('clients.client_id') . " ORDER BY client_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_clients)) {
|
||||
$client_id_select = intval($row['client_id']);
|
||||
$client_name_select = escapeHtml($row['client_name']);
|
||||
|
||||
@@ -87,7 +87,7 @@ ob_start();
|
||||
<option><?= $trip_destination ?></option>
|
||||
<?php
|
||||
|
||||
$sql_locations_select = mysqli_query($mysqli, "SELECT * FROM locations WHERE location_archived_at IS NULL AND location_client_id = $client_id ORDER BY location_name ASC");
|
||||
$sql_locations_select = mysqli_query($mysqli, "SELECT location_address, location_city, location_name, location_state, location_zip FROM locations WHERE location_archived_at IS NULL AND location_client_id = $client_id ORDER BY location_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_locations_select)) {
|
||||
$location_name = escapeHtml($row['location_name']);
|
||||
$location_address = escapeHtml($row['location_address']);
|
||||
@@ -121,7 +121,7 @@ ob_start();
|
||||
<option value="">- Driver -</option>
|
||||
<?php
|
||||
|
||||
$sql_users = mysqli_query($mysqli, "SELECT * FROM users
|
||||
$sql_users = mysqli_query($mysqli, "SELECT users.user_id, user_name FROM users
|
||||
LEFT JOIN user_settings on users.user_id = user_settings.user_id
|
||||
WHERE (users.user_id = $trip_user_id) OR (user_archived_at IS NULL AND user_status = 1) ORDER BY user_name ASC"
|
||||
);
|
||||
@@ -151,7 +151,7 @@ ob_start();
|
||||
<option value="">- Client (Optional) -</option>
|
||||
<?php
|
||||
|
||||
$sql_clients = mysqli_query($mysqli, "SELECT * FROM clients WHERE client_archived_at IS NULL " . clientScopeSql('clients.client_id') . " ORDER BY client_name ASC");
|
||||
$sql_clients = mysqli_query($mysqli, "SELECT client_id, client_name FROM clients WHERE client_archived_at IS NULL " . clientScopeSql('clients.client_id') . " ORDER BY client_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_clients)) {
|
||||
$client_id_select = intval($row['client_id']);
|
||||
$client_name_select = escapeHtml($row['client_name']);
|
||||
|
||||
@@ -29,7 +29,7 @@ ob_start();
|
||||
<select class="form-control" name="vendor_template_id" required>
|
||||
<option value="">- Select Template -</option>
|
||||
<?php
|
||||
$sql_vendor_templates = mysqli_query($mysqli, "SELECT * FROM vendor_templates WHERE vendor_template_archived_at IS NULL ORDER BY vendor_template_name ASC");
|
||||
$sql_vendor_templates = mysqli_query($mysqli, "SELECT vendor_template_id, vendor_template_name FROM vendor_templates WHERE vendor_template_archived_at IS NULL ORDER BY vendor_template_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_vendor_templates)) {
|
||||
$vendor_template_id = intval($row['vendor_template_id']);
|
||||
$vendor_template_name = escapeHtml($row['vendor_template_name']);
|
||||
|
||||
2
agent/modals/vendor/vendor_edit.php
vendored
2
agent/modals/vendor/vendor_edit.php
vendored
@@ -112,7 +112,7 @@ ob_start();
|
||||
<option value="0">- None -</option>
|
||||
<?php
|
||||
|
||||
$sql_vendor_templates = mysqli_query($mysqli, "SELECT * FROM vendor_templates WHERE vendor_template_archived_at IS NULL ORDER BY vendor_template_name ASC");
|
||||
$sql_vendor_templates = mysqli_query($mysqli, "SELECT vendor_template_id, vendor_template_name FROM vendor_templates WHERE vendor_template_archived_at IS NULL ORDER BY vendor_template_name ASC");
|
||||
while ($row = mysqli_fetch_assoc($sql_vendor_templates)) {
|
||||
$vendor_template_id_select = $row['vendor_template_id'];
|
||||
$vendor_template_name_select = escapeHtml($row['vendor_template_name']); ?>
|
||||
|
||||
@@ -58,7 +58,9 @@ if ($client_url && isset($_GET['location']) && !empty($_GET['location'])) {
|
||||
|
||||
$sql = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT SQL_CALC_FOUND_ROWS * FROM networks
|
||||
"SELECT SQL_CALC_FOUND_ROWS client_id, client_name, location_name, network, network_archived_at, network_description,
|
||||
network_dhcp_range, network_gateway, network_id, network_location_id, network_name,
|
||||
network_primary_dns, network_secondary_dns, network_vlan FROM networks
|
||||
LEFT JOIN clients ON client_id = network_client_id
|
||||
LEFT JOIN locations ON location_id = network_location_id
|
||||
WHERE $archive_query
|
||||
|
||||
@@ -18,7 +18,8 @@ if (isset($_GET['dismissed'])) {
|
||||
|
||||
$sql = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT SQL_CALC_FOUND_ROWS * FROM notifications
|
||||
"SELECT SQL_CALC_FOUND_ROWS client_id, client_name, notification, notification_dismissed_at, notification_id,
|
||||
notification_timestamp, notification_type FROM notifications
|
||||
LEFT JOIN clients ON notification_client_id = client_id
|
||||
WHERE (notification_type LIKE '%$q%' OR notification LIKE '%$q%')
|
||||
AND DATE(notification_timestamp) BETWEEN '$dtf' AND '$dtt'
|
||||
|
||||
@@ -540,7 +540,7 @@ if (isset($_POST['bulk_transfer_client_asset'])) {
|
||||
$new_asset_id = mysqli_insert_id($mysqli);
|
||||
|
||||
// Transfer all Interfaces over too
|
||||
$sql_interfaces = mysqli_query($mysqli, "SELECT * FROM asset_interfaces WHERE interface_asset_id = $current_asset_id");
|
||||
$sql_interfaces = mysqli_query($mysqli, "SELECT interface_mac, interface_name, interface_primary FROM asset_interfaces WHERE interface_asset_id = $current_asset_id");
|
||||
|
||||
while ($row = mysqli_fetch_assoc($sql_interfaces)) {
|
||||
$interface_name = escapeSql($row['interface_name']);
|
||||
|
||||
@@ -216,7 +216,7 @@ if (isset($_GET['archive_client'])) {
|
||||
mysqli_query($mysqli, "UPDATE clients SET client_archived_at = NOW() WHERE client_id = $client_id");
|
||||
|
||||
// Stop recurring invoices
|
||||
$sql_recurring_invoices = mysqli_query($mysqli, "SELECT * FROM recurring_invoices WHERE recurring_invoice_client_id = $client_id AND recurring_invoice_status = 1");
|
||||
$sql_recurring_invoices = mysqli_query($mysqli, "SELECT recurring_invoice_id FROM recurring_invoices WHERE recurring_invoice_client_id = $client_id AND recurring_invoice_status = 1");
|
||||
while ($row = mysqli_fetch_assoc($sql_recurring_invoices)) {
|
||||
$recurring_invoice_id = intval($row['recurring_invoice_id']);
|
||||
mysqli_query($mysqli,"UPDATE recurring_invoices SET recurring_invoice_status = 0 WHERE recurring_invoice_id = $recurring_invoice_id AND recurring_invoice_client_id = $client_id");
|
||||
|
||||
@@ -820,7 +820,7 @@ if (isset($_GET['anonymize_contact'])) {
|
||||
|
||||
|
||||
// Get all tickets this contact raised
|
||||
$contact_tickets_sql = mysqli_query($mysqli, "SELECT * FROM tickets WHERE ticket_client_id = $client_id AND ticket_contact_id = $contact_id");
|
||||
$contact_tickets_sql = mysqli_query($mysqli, "SELECT ticket_details, ticket_id, ticket_subject FROM tickets WHERE ticket_client_id = $client_id AND ticket_contact_id = $contact_id");
|
||||
while ($ticket = mysqli_fetch_assoc($contact_tickets_sql)) {
|
||||
|
||||
$ticket_id = intval($ticket['ticket_id']);
|
||||
@@ -839,7 +839,7 @@ if (isset($_GET['anonymize_contact'])) {
|
||||
mysqli_query($mysqli,"UPDATE tickets SET ticket_details = '$details' WHERE ticket_id = $ticket_id");
|
||||
|
||||
// Redact contact name or email in the replies of all tickets they raised
|
||||
$ticket_replies_sql = mysqli_query($mysqli, "SELECT * FROM ticket_replies WHERE ticket_reply_ticket_id = $ticket_id");
|
||||
$ticket_replies_sql = mysqli_query($mysqli, "SELECT ticket_reply, ticket_reply_id FROM ticket_replies WHERE ticket_reply_ticket_id = $ticket_id");
|
||||
|
||||
while($ticket_reply = mysqli_fetch_assoc($ticket_replies_sql)) {
|
||||
$ticket_reply_id = intval($ticket_reply['ticket_reply_id']);
|
||||
|
||||
@@ -78,7 +78,7 @@ if (isset($_GET['delete_folder'])) {
|
||||
mysqli_query($mysqli,"DELETE FROM folders WHERE folder_id = $folder_id");
|
||||
|
||||
// Move files in deleted folder back to the root folder /
|
||||
$sql_documents = mysqli_query($mysqli,"SELECT * FROM documents WHERE document_folder_id = $folder_id");
|
||||
$sql_documents = mysqli_query($mysqli,"SELECT document_id FROM documents WHERE document_folder_id = $folder_id");
|
||||
while($row = mysqli_fetch_assoc($sql_documents)) {
|
||||
$document_id = intval($row['document_id']);
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ if (isset($_POST['edit_invoice'])) {
|
||||
enforceClientAccess();
|
||||
|
||||
// Calculate new total
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM invoice_items WHERE item_invoice_id = $invoice_id");
|
||||
$sql = mysqli_query($mysqli,"SELECT item_total FROM invoice_items WHERE item_invoice_id = $invoice_id");
|
||||
$invoice_amount = 0;
|
||||
while($row = mysqli_fetch_assoc($sql)) {
|
||||
$item_total = floatval($row['item_total']);
|
||||
@@ -138,7 +138,8 @@ if (isset($_POST['add_invoice_copy'])) {
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO history SET history_status = 'Draft', history_description = 'Copied INVOICE!', history_invoice_id = $new_invoice_id");
|
||||
|
||||
$sql_items = mysqli_query($mysqli,"SELECT * FROM invoice_items WHERE item_invoice_id = $invoice_id");
|
||||
$sql_items = mysqli_query($mysqli,"SELECT item_description, item_id, item_name, item_order, item_price, item_quantity, item_subtotal,
|
||||
item_tax, item_tax_id, item_total FROM invoice_items WHERE item_invoice_id = $invoice_id");
|
||||
while($row = mysqli_fetch_assoc($sql_items)) {
|
||||
$item_id = intval($row['item_id']);
|
||||
$item_name = escapeSql($row['item_name']);
|
||||
@@ -271,7 +272,7 @@ if (isset($_GET['delete_invoice'])) {
|
||||
mysqli_query($mysqli,"DELETE FROM invoices WHERE invoice_id = $invoice_id");
|
||||
|
||||
//Delete Items Associated with the Invoice
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM invoice_items WHERE item_invoice_id = $invoice_id");
|
||||
$sql = mysqli_query($mysqli,"SELECT item_id FROM invoice_items WHERE item_invoice_id = $invoice_id");
|
||||
while($row = mysqli_fetch_assoc($sql)) {
|
||||
$item_id = intval($row['item_id']);
|
||||
mysqli_query($mysqli,"DELETE FROM invoice_items WHERE item_id = $item_id");
|
||||
@@ -372,7 +373,7 @@ if (isset($_POST['add_invoice_item'])) {
|
||||
$invoice_discount = floatval($row['invoice_discount_amount']);
|
||||
|
||||
//add up all line items
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM invoice_items WHERE item_invoice_id = $invoice_id");
|
||||
$sql = mysqli_query($mysqli,"SELECT item_total FROM invoice_items WHERE item_invoice_id = $invoice_id");
|
||||
$invoice_total = 0;
|
||||
while($row = mysqli_fetch_assoc($sql)) {
|
||||
$item_total = floatval($row['item_total']);
|
||||
@@ -974,7 +975,7 @@ if (isset($_GET['export_invoice_pdf'])) {
|
||||
$sub_total = 0;
|
||||
$total_tax = 0;
|
||||
|
||||
$sql_items = mysqli_query($mysqli, "SELECT * FROM invoice_items WHERE item_invoice_id = $invoice_id ORDER BY item_order ASC");
|
||||
$sql_items = mysqli_query($mysqli, "SELECT item_description, item_name, item_price, item_quantity, item_tax, item_total FROM invoice_items WHERE item_invoice_id = $invoice_id ORDER BY item_order ASC");
|
||||
while ($item = mysqli_fetch_assoc($sql_items)) {
|
||||
$name = $item['item_name'];
|
||||
$desc = $item['item_description'];
|
||||
@@ -1140,7 +1141,7 @@ if (isset($_GET['export_invoice_packing_slip'])) {
|
||||
$sub_total = 0;
|
||||
$total_tax = 0;
|
||||
|
||||
$sql_items = mysqli_query($mysqli, "SELECT * FROM invoice_items WHERE item_invoice_id = $invoice_id ORDER BY item_order ASC");
|
||||
$sql_items = mysqli_query($mysqli, "SELECT item_name, item_quantity FROM invoice_items WHERE item_invoice_id = $invoice_id ORDER BY item_order ASC");
|
||||
while ($item = mysqli_fetch_assoc($sql_items)) {
|
||||
$name = $item['item_name'];
|
||||
$qty = $item['item_quantity'];
|
||||
|
||||
@@ -99,7 +99,8 @@ if (isset($_POST['add_quote_copy'])) {
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO history SET history_status = 'Draft', history_description = 'Quote copied!', history_quote_id = $new_quote_id");
|
||||
|
||||
$sql_items = mysqli_query($mysqli,"SELECT * FROM quote_items WHERE item_quote_id = $quote_id");
|
||||
$sql_items = mysqli_query($mysqli,"SELECT item_description, item_id, item_name, item_order, item_price, item_quantity, item_subtotal,
|
||||
item_tax, item_tax_id, item_total FROM quote_items WHERE item_quote_id = $quote_id");
|
||||
while($row = mysqli_fetch_assoc($sql_items)) {
|
||||
$item_id = intval($row['item_id']);
|
||||
$item_name = escapeSql($row['item_name']);
|
||||
@@ -172,7 +173,8 @@ if (isset($_POST['add_quote_to_invoice'])) {
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO history SET history_status = 'Draft', history_description = 'Invoice created from quote $quote_prefix$quote_number', history_invoice_id = $new_invoice_id");
|
||||
|
||||
$sql_items = mysqli_query($mysqli,"SELECT * FROM quote_items WHERE item_quote_id = $quote_id");
|
||||
$sql_items = mysqli_query($mysqli,"SELECT item_description, item_id, item_name, item_order, item_price, item_quantity, item_subtotal,
|
||||
item_tax, item_tax_id, item_total FROM quote_items WHERE item_quote_id = $quote_id");
|
||||
while($row = mysqli_fetch_assoc($sql_items)) {
|
||||
$item_id = intval($row['item_id']);
|
||||
$item_name = escapeSql($row['item_name']);
|
||||
@@ -260,7 +262,7 @@ if (isset($_POST['add_quote_item'])) {
|
||||
$client_id = intval($row['quote_client_id']);
|
||||
|
||||
//add up the total of all items
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM quote_items WHERE item_quote_id = $quote_id");
|
||||
$sql = mysqli_query($mysqli,"SELECT item_total FROM quote_items WHERE item_quote_id = $quote_id");
|
||||
$quote_amount = 0;
|
||||
while($row = mysqli_fetch_assoc($sql)) {
|
||||
$item_total = floatval($row['item_total']);
|
||||
@@ -385,7 +387,7 @@ if (isset($_POST['edit_quote'])) {
|
||||
enforceClientAccess();
|
||||
|
||||
//Calculate the new quote amount
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM quote_items WHERE item_quote_id = $quote_id");
|
||||
$sql = mysqli_query($mysqli,"SELECT item_total FROM quote_items WHERE item_quote_id = $quote_id");
|
||||
$quote_amount = 0;
|
||||
while($row = mysqli_fetch_assoc($sql)) {
|
||||
$item_total = floatval($row['item_total']);
|
||||
@@ -423,7 +425,7 @@ if (isset($_GET['delete_quote'])) {
|
||||
mysqli_query($mysqli,"DELETE FROM quotes WHERE quote_id = $quote_id");
|
||||
|
||||
//Delete Items Associated with the Quote
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM quote_items WHERE item_quote_id = $quote_id");
|
||||
$sql = mysqli_query($mysqli,"SELECT item_id FROM quote_items WHERE item_quote_id = $quote_id");
|
||||
while($row = mysqli_fetch_assoc($sql)) {;
|
||||
$item_id = intval($row['item_id']);
|
||||
mysqli_query($mysqli,"DELETE FROM quote_items WHERE item_id = $item_id");
|
||||
@@ -918,7 +920,7 @@ if (isset($_GET['export_quote_pdf'])) {
|
||||
$sub_total = 0;
|
||||
$total_tax = 0;
|
||||
|
||||
$sql_items = mysqli_query($mysqli, "SELECT * FROM quote_items WHERE item_quote_id = $quote_id ORDER BY item_order ASC");
|
||||
$sql_items = mysqli_query($mysqli, "SELECT item_description, item_name, item_price, item_quantity, item_tax, item_total FROM quote_items WHERE item_quote_id = $quote_id ORDER BY item_order ASC");
|
||||
while ($item = mysqli_fetch_assoc($sql_items)) {
|
||||
$name = $item['item_name'];
|
||||
$desc = $item['item_description'];
|
||||
|
||||
@@ -46,7 +46,8 @@ if (isset($_POST['add_invoice_recurring'])) {
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO history SET history_status = 'Draft', history_description = 'Recurring Invoice Created from INVOICE!', history_recurring_invoice_id = $recurring_invoice_id");
|
||||
|
||||
$sql_items = mysqli_query($mysqli,"SELECT * FROM invoice_items WHERE item_invoice_id = $invoice_id");
|
||||
$sql_items = mysqli_query($mysqli,"SELECT item_description, item_id, item_name, item_order, item_price, item_quantity, item_subtotal,
|
||||
item_tax, item_tax_id, item_total FROM invoice_items WHERE item_invoice_id = $invoice_id");
|
||||
while($row = mysqli_fetch_assoc($sql_items)) {
|
||||
$item_id = intval($row['item_id']);
|
||||
$item_name = escapeSql($row['item_name']);
|
||||
@@ -133,7 +134,7 @@ if (isset($_POST['edit_recurring_invoice'])) {
|
||||
enforceClientAccess();
|
||||
|
||||
//Calculate new total
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM recurring_invoice_items WHERE item_recurring_invoice_id = $recurring_invoice_id");
|
||||
$sql = mysqli_query($mysqli,"SELECT item_total FROM recurring_invoice_items WHERE item_recurring_invoice_id = $recurring_invoice_id");
|
||||
$recurring_invoice_amount = 0;
|
||||
while($row = mysqli_fetch_assoc($sql)) {
|
||||
$item_total = floatval($row['item_total']);
|
||||
@@ -174,7 +175,7 @@ if (isset($_GET['delete_recurring_invoice'])) {
|
||||
mysqli_query($mysqli,"DELETE FROM recurring_invoices WHERE recurring_invoice_id = $recurring_invoice_id");
|
||||
|
||||
//Delete Items Associated with the Recurring
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM recurring_invoice_items WHERE item_recurring_invoice_id = $recurring_invoice_id");
|
||||
$sql = mysqli_query($mysqli,"SELECT item_id FROM recurring_invoice_items WHERE item_recurring_invoice_id = $recurring_invoice_id");
|
||||
while($row = mysqli_fetch_assoc($sql)) {
|
||||
$item_id = intval($row['item_id']);
|
||||
mysqli_query($mysqli,"DELETE FROM recurring_invoice_items WHERE item_id = $item_id");
|
||||
@@ -237,7 +238,7 @@ if (isset($_POST['add_recurring_invoice_item'])) {
|
||||
$client_id = intval($row['recurring_invoice_client_id']);
|
||||
|
||||
//add up all the items
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM recurring_invoice_items WHERE item_recurring_invoice_id = $recurring_invoice_id");
|
||||
$sql = mysqli_query($mysqli,"SELECT item_total FROM recurring_invoice_items WHERE item_recurring_invoice_id = $recurring_invoice_id");
|
||||
$recurring_invoice_amount = 0;
|
||||
while($row = mysqli_fetch_assoc($sql)) {
|
||||
$item_total = floatval($row['item_total']);
|
||||
|
||||
@@ -2996,7 +2996,7 @@ if (isset($_POST['edit_ticket_schedule'])) {
|
||||
//TODO make this configurable
|
||||
$start = date('Y-m-d H:i:s', strtotime($schedule) - 7200);
|
||||
$end = date('Y-m-d H:i:s', strtotime($schedule) + 7200);
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM tickets WHERE ticket_schedule BETWEEN '$start' AND '$end' AND ticket_id != $ticket_id");
|
||||
$sql = mysqli_query($mysqli, "SELECT ticket_id, ticket_schedule, ticket_subject FROM tickets WHERE ticket_schedule BETWEEN '$start' AND '$end' AND ticket_id != $ticket_id");
|
||||
if (mysqli_num_rows($sql) > 0) {
|
||||
$conflicting_tickets = [];
|
||||
while ($row = mysqli_fetch_assoc($sql)) {
|
||||
|
||||
@@ -112,7 +112,7 @@ if (isset($_GET['project_id'])) {
|
||||
|
||||
// Get All Tasks
|
||||
$sql_tasks = mysqli_query($mysqli,
|
||||
"SELECT * FROM tickets, tasks
|
||||
"SELECT task_completed_at, task_id, task_name FROM tickets, tasks
|
||||
WHERE ticket_id = task_ticket_id
|
||||
AND ticket_project_id = $project_id
|
||||
ORDER BY task_created_at ASC"
|
||||
|
||||
@@ -283,7 +283,8 @@ if (isset($_GET['quote_id'])) {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php $sql_items = mysqli_query($mysqli, "SELECT * FROM quote_items WHERE item_quote_id = $quote_id ORDER BY item_order ASC"); ?>
|
||||
<?php $sql_items = mysqli_query($mysqli, "SELECT item_created_at, item_description, item_id, item_name, item_price, item_quantity, item_tax,
|
||||
item_tax_id, item_total FROM quote_items WHERE item_quote_id = $quote_id ORDER BY item_order ASC"); ?>
|
||||
|
||||
<div class="row mb-3">
|
||||
<div class="col-md-12">
|
||||
|
||||
@@ -20,7 +20,9 @@ enforceUserPermission('module_sales');
|
||||
|
||||
$sql = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT SQL_CALC_FOUND_ROWS * FROM quotes
|
||||
"SELECT SQL_CALC_FOUND_ROWS category_id, category_name, client_currency_code, client_id, client_name, client_net_terms,
|
||||
quote_amount, quote_created_at, quote_currency_code, quote_date, quote_discount_amount,
|
||||
quote_expire, quote_id, quote_number, quote_prefix, quote_scope, quote_status FROM quotes
|
||||
LEFT JOIN clients ON quote_client_id = client_id
|
||||
LEFT JOIN categories ON quote_category_id = category_id
|
||||
WHERE (CONCAT(quote_prefix,quote_number) LIKE '%$q%' OR quote_scope LIKE '%$q%' OR category_name LIKE '%$q%' OR quote_status LIKE '%$q%' OR quote_amount LIKE '%$q%' OR client_name LIKE '%$q%')
|
||||
|
||||
@@ -11,7 +11,9 @@ enforceUserPermission('module_support');
|
||||
|
||||
$sql = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT SQL_CALC_FOUND_ROWS * FROM racks
|
||||
"SELECT SQL_CALC_FOUND_ROWS location_name, rack_created_at, rack_depth, rack_description, rack_id, rack_location_id,
|
||||
rack_model, rack_name, rack_notes, rack_photo, rack_physical_location, rack_type,
|
||||
rack_units FROM racks
|
||||
LEFT JOIN locations ON location_id = rack_location_id
|
||||
WHERE rack_client_id = $client_id
|
||||
AND rack_$archive_query
|
||||
|
||||
@@ -11,7 +11,13 @@ enforceUserPermission('module_financial');
|
||||
|
||||
$sql = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT SQL_CALC_FOUND_ROWS * FROM recurring_expenses
|
||||
"SELECT SQL_CALC_FOUND_ROWS account_name, category_name, client_name, recurring_expense_account_id,
|
||||
recurring_expense_amount, recurring_expense_category_id, recurring_expense_client_id,
|
||||
recurring_expense_created_at, recurring_expense_currency_code, recurring_expense_day,
|
||||
recurring_expense_description, recurring_expense_frequency, recurring_expense_id,
|
||||
recurring_expense_last_sent, recurring_expense_month, recurring_expense_next_date,
|
||||
recurring_expense_payment_method, recurring_expense_reference, recurring_expense_status,
|
||||
recurring_expense_vendor_id, vendor_name FROM recurring_expenses
|
||||
LEFT JOIN categories ON recurring_expense_category_id = category_id
|
||||
LEFT JOIN vendors ON recurring_expense_vendor_id = vendor_id
|
||||
LEFT JOIN accounts ON recurring_expense_account_id = account_id
|
||||
|
||||
@@ -252,7 +252,8 @@ if (isset($_GET['recurring_invoice_id'])) {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php $sql_items = mysqli_query($mysqli, "SELECT * FROM recurring_invoice_items WHERE item_recurring_invoice_id = $recurring_invoice_id ORDER BY item_order ASC"); ?>
|
||||
<?php $sql_items = mysqli_query($mysqli, "SELECT item_created_at, item_description, item_id, item_name, item_price, item_quantity, item_tax,
|
||||
item_tax_id, item_total FROM recurring_invoice_items WHERE item_recurring_invoice_id = $recurring_invoice_id ORDER BY item_order ASC"); ?>
|
||||
|
||||
<div class="row mb-3">
|
||||
<div class="col-md-12">
|
||||
|
||||
@@ -139,7 +139,7 @@
|
||||
<?php } ?>
|
||||
|
||||
<?php
|
||||
$sql_custom_links = mysqli_query($mysqli, "SELECT * FROM custom_links
|
||||
$sql_custom_links = mysqli_query($mysqli, "SELECT custom_link_icon, custom_link_name, custom_link_new_tab, custom_link_uri FROM custom_links
|
||||
WHERE custom_link_location = 5 AND custom_link_archived_at IS NULL
|
||||
ORDER BY custom_link_order ASC, custom_link_name ASC"
|
||||
);
|
||||
|
||||
@@ -33,7 +33,9 @@ if (!$client_url) {
|
||||
// Overview SQL query
|
||||
$sql = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT SQL_CALC_FOUND_ROWS * FROM services
|
||||
"SELECT SQL_CALC_FOUND_ROWS client_id, client_name, service_backup, service_category, service_created_at,
|
||||
service_description, service_id, service_importance, service_name, service_notes,
|
||||
service_review_due, service_updated_at FROM services
|
||||
LEFT JOIN clients ON client_id = service_client_id
|
||||
WHERE (service_name LIKE '%$q%' OR service_description LIKE '%$q%' OR service_category LIKE '%$q%' OR client_name LIKE '%$q%')
|
||||
AND client_archived_at IS NULL
|
||||
|
||||
@@ -264,7 +264,9 @@ if (isset($_GET['ticket_id'])) {
|
||||
))['user_names']);
|
||||
|
||||
// Get ticket replies
|
||||
$sql_ticket_replies = mysqli_query($mysqli, "SELECT * FROM ticket_replies
|
||||
$sql_ticket_replies = mysqli_query($mysqli, "SELECT contact_name, contact_photo, ticket_reply, ticket_reply_created_at, ticket_reply_id,
|
||||
ticket_reply_time_worked, ticket_reply_type, ticket_reply_updated_at, user_avatar, user_id,
|
||||
user_name FROM ticket_replies
|
||||
LEFT JOIN users ON ticket_reply_by = user_id
|
||||
LEFT JOIN contacts ON ticket_reply_by = contact_id
|
||||
WHERE ticket_reply_ticket_id = $ticket_id
|
||||
@@ -297,7 +299,7 @@ if (isset($_GET['ticket_id'])) {
|
||||
$watcher_count = mysqli_num_rows($sql_ticket_watchers);
|
||||
|
||||
// Get Additional Assets
|
||||
$sql_additional_assets = mysqli_query($mysqli, "SELECT * FROM assets, ticket_assets
|
||||
$sql_additional_assets = mysqli_query($mysqli, "SELECT assets.asset_id, asset_name, asset_type FROM assets, ticket_assets
|
||||
WHERE assets.asset_id = ticket_assets.asset_id
|
||||
AND ticket_id = $ticket_id
|
||||
AND assets.asset_id != $asset_id"
|
||||
|
||||
@@ -17,7 +17,8 @@ if (isset($_GET['client_id'])) {
|
||||
|
||||
$sql = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT SQL_CALC_FOUND_ROWS * FROM trips
|
||||
"SELECT SQL_CALC_FOUND_ROWS client_id, client_name, round_trip, trip_archived_at, trip_created_at, trip_date,
|
||||
trip_destination, trip_id, trip_miles, trip_purpose, trip_source, trip_user_id, user_name FROM trips
|
||||
LEFT JOIN clients ON trip_client_id = client_id
|
||||
LEFT JOIN users ON trip_user_id = user_id
|
||||
WHERE (trip_purpose LIKE '%$q%' OR trip_source LIKE '%$q%' OR trip_destination LIKE '%$q%' OR trip_miles LIKE '%$q%' OR client_name LIKE '%$q%' OR user_name LIKE '%$q%')
|
||||
|
||||
@@ -17,7 +17,10 @@ if (isset($_GET['client_id'])) {
|
||||
|
||||
$sql = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT SQL_CALC_FOUND_ROWS * FROM vendors
|
||||
"SELECT SQL_CALC_FOUND_ROWS vendor_account_number, vendor_archived_at, vendor_code, vendor_contact_name,
|
||||
vendor_created_at, vendor_description, vendor_email, vendor_extension, vendor_hours,
|
||||
vendor_id, vendor_name, vendor_notes, vendor_phone, vendor_phone_country_code, vendor_sla,
|
||||
vendor_templates.vendor_template_id, vendor_template_name, vendor_website FROM vendors
|
||||
LEFT JOIN clients ON client_id = vendor_client_id
|
||||
LEFT JOIN vendor_templates ON vendors.vendor_template_id = vendor_templates.vendor_template_id
|
||||
WHERE vendor_$archive_query
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user