mirror of https://github.com/itflow-org/itflow
Tidy code
This commit is contained in:
parent
45b686dafc
commit
e42095a85e
|
|
@ -130,23 +130,23 @@ function addReply($from_email, $date, $subject, $ticket_number, $message)
|
|||
|
||||
// Lookup the ticket ID
|
||||
$row = mysqli_fetch_array(mysqli_query($mysqli, "SELECT ticket_id, ticket_subject, ticket_status, ticket_contact_id, ticket_client_id, tickets.company_id, contact_email
|
||||
FROM tickets
|
||||
LEFT JOIN contacts on tickets.ticket_contact_id = contacts.contact_id
|
||||
WHERE ticket_number = '$ticket_number' LIMIT 1"));
|
||||
FROM tickets
|
||||
LEFT JOIN contacts on tickets.ticket_contact_id = contacts.contact_id
|
||||
WHERE ticket_number = $ticket_number LIMIT 1"));
|
||||
|
||||
if ($row) {
|
||||
|
||||
// Get ticket details
|
||||
$ticket_id = $row['ticket_id'];
|
||||
$ticket_id = intval($row['ticket_id']);
|
||||
$ticket_status = $row['ticket_status'];
|
||||
$ticket_reply_contact = $row['ticket_contact_id'];
|
||||
$ticket_reply_contact = intval($row['ticket_contact_id']);
|
||||
$ticket_contact_email = $row['contact_email'];
|
||||
$client_id = $row['ticket_client_id'];
|
||||
$company_id = $row['company_id'];
|
||||
$client_id = intval($row['ticket_client_id']);
|
||||
$company_id = intval($row['company_id']);
|
||||
|
||||
// Check ticket isn't closed
|
||||
if ($ticket_status == "Closed") {
|
||||
mysqli_query($mysqli, "INSERT INTO notifications SET notification_type = 'Ticket', notification = 'Email parser: $from_email attempted to re-open ticket $config_ticket_prefix$ticket_number (ID $ticket_id) - check inbox manually to see email', notification_timestamp = NOW(), notification_client_id = '$client_id', company_id = '$company_id'");
|
||||
mysqli_query($mysqli, "INSERT INTO notifications SET notification_type = 'Ticket', notification = 'Email parser: $from_email attempted to re-open ticket $config_ticket_prefix$ticket_number (ID $ticket_id) - check inbox manually to see email', notification_client_id = $client_id, company_id = $company_id");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -159,7 +159,7 @@ function addReply($from_email, $date, $subject, $ticket_number, $message)
|
|||
if ($row) {
|
||||
|
||||
// Contact is known - we can keep the reply type as client
|
||||
$ticket_reply_contact = $row['contact_id'];
|
||||
$ticket_reply_contact = intval($row['contact_id']);
|
||||
|
||||
} else {
|
||||
// Mark the reply as internal as we don't recognise the contact (so the actual contact doesn't see it, and the tech can edit/delete if needed)
|
||||
|
|
@ -173,13 +173,13 @@ function addReply($from_email, $date, $subject, $ticket_number, $message)
|
|||
$comment = trim(mysqli_real_escape_string($mysqli, $message));
|
||||
|
||||
// Add the comment
|
||||
mysqli_query($mysqli, "INSERT INTO ticket_replies SET ticket_reply = '$comment', ticket_reply_type = '$ticket_reply_type', ticket_reply_time_worked = '00:00:00', ticket_reply_created_at = NOW(), ticket_reply_by = '$ticket_reply_contact', ticket_reply_ticket_id = '$ticket_id', company_id = '$company_id'");
|
||||
mysqli_query($mysqli, "INSERT INTO ticket_replies SET ticket_reply = '$comment', ticket_reply_type = '$ticket_reply_type', ticket_reply_time_worked = '00:00:00', ticket_reply_by = $ticket_reply_contact, ticket_reply_ticket_id = $ticket_id, company_id = $company_id");
|
||||
|
||||
// Update Ticket Last Response Field & set ticket to open as client has replied
|
||||
mysqli_query($mysqli, "UPDATE tickets SET ticket_status = 'Open', ticket_updated_at = NOW() WHERE ticket_id = $ticket_id AND ticket_client_id = '$client_id' LIMIT 1");
|
||||
mysqli_query($mysqli, "UPDATE tickets SET ticket_status = 'Open' WHERE ticket_id = $ticket_id AND ticket_client_id = $client_id LIMIT 1");
|
||||
|
||||
echo "Updated existing ticket.<br>";
|
||||
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Ticket', log_action = 'Update', log_description = 'Email parser: Client contact $from_email updated ticket $config_ticket_prefix$ticket_number ($subject)', log_created_at = NOW(), log_client_id = $client_id, company_id = $company_id");
|
||||
mysqli_query($mysqli, "INSERT INTO logs SET log_type = 'Ticket', log_action = 'Update', log_description = 'Email parser: Client contact $from_email updated ticket $config_ticket_prefix$ticket_number ($subject)', log_client_id = $client_id, company_id = $company_id");
|
||||
|
||||
return true;
|
||||
|
||||
|
|
@ -267,10 +267,10 @@ if ($emails) {
|
|||
if ($row) {
|
||||
// Sender exists as a contact
|
||||
$contact_name = $row['contact_name'];
|
||||
$contact_id = $row['contact_id'];
|
||||
$contact_id = intval($row['contact_id']);
|
||||
$contact_email = $row['contact_email'];
|
||||
$client_id = $row['contact_client_id'];
|
||||
$company_id = $row['company_id'];
|
||||
$client_id = intval($row['contact_client_id']);
|
||||
$company_id = intval($row['company_id']);
|
||||
|
||||
if (addTicket($contact_id, $contact_name, $contact_email, $client_id, $company_id, $date, $subject, $message)) {
|
||||
$email_processed = true;
|
||||
|
|
@ -288,8 +288,8 @@ if ($emails) {
|
|||
// We found a match - create a contact under this client and raise a ticket for them
|
||||
|
||||
// Client details
|
||||
$client_id = $row['client_id'];
|
||||
$company_id = $row['company_id'];
|
||||
$client_id = intval($row['client_id']);
|
||||
$company_id = intval($row['company_id']);
|
||||
|
||||
// Contact details
|
||||
$password = password_hash(randomString(), PASSWORD_DEFAULT);
|
||||
|
|
|
|||
|
|
@ -1,191 +0,0 @@
|
|||
<?php
|
||||
|
||||
require_once("inc_all.php");
|
||||
|
||||
if (isset($_GET['year'])) {
|
||||
$year = intval($_GET['year']);
|
||||
} else {
|
||||
$year = date('Y');
|
||||
}
|
||||
|
||||
// GET unique years from expenses, payments and revenues
|
||||
$sql_payment_years = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT YEAR(expense_date) AS all_years FROM expenses
|
||||
WHERE company_id = $session_company_id
|
||||
UNION DISTINCT SELECT YEAR(payment_date) FROM payments WHERE company_id = $session_company_id
|
||||
UNION DISTINCT SELECT YEAR(revenue_date) FROM revenues WHERE company_id = $session_company_id
|
||||
ORDER BY all_years DESC"
|
||||
);
|
||||
|
||||
// Get Total Clients added
|
||||
$sql_clients = mysqli_fetch_assoc(mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT COUNT('client_id') AS clients_added FROM clients
|
||||
WHERE YEAR(client_created_at) = $year
|
||||
AND company_id = $session_company_id"
|
||||
));
|
||||
$clients_added = $sql_clients['clients_added'];
|
||||
|
||||
// Get Total contacts added
|
||||
$sql_contacts = mysqli_fetch_assoc(mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT COUNT('contact_id') AS contacts_added FROM contacts
|
||||
WHERE YEAR(contact_created_at) = $year
|
||||
AND company_id = $session_company_id"
|
||||
));
|
||||
$contacts_added = $sql_contacts['contacts_added'];
|
||||
|
||||
// Get Total assets added
|
||||
$sql_assets = mysqli_fetch_assoc(mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT COUNT('asset_id') AS assets_added FROM assets
|
||||
WHERE YEAR(asset_created_at) = $year
|
||||
AND company_id = $session_company_id"
|
||||
));
|
||||
$assets_added = $sql_assets['assets_added'];
|
||||
|
||||
// Ticket count
|
||||
$sql_tickets = mysqli_fetch_assoc(mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT COUNT('ticket_id') AS active_tickets
|
||||
FROM tickets
|
||||
WHERE ticket_status != 'Closed'
|
||||
AND company_id = $session_company_id"
|
||||
));
|
||||
$active_tickets = $sql_tickets['active_tickets'];
|
||||
|
||||
// Expiring domains (but not ones that have already expired)
|
||||
$sql_domains_expiring = mysqli_fetch_assoc(mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT COUNT('domain_id') as expiring_domains
|
||||
FROM domains
|
||||
WHERE domain_expire != '0000-00-00'
|
||||
AND domain_expire > CURRENT_DATE
|
||||
AND domain_expire < CURRENT_DATE + INTERVAL 30 DAY
|
||||
AND domain_archived_at IS NULL
|
||||
AND company_id = $session_company_id"
|
||||
));
|
||||
$expiring_domains = $sql_domains_expiring['expiring_domains'];
|
||||
|
||||
// Expiring Certificates (but not ones that have already expired)
|
||||
$sql_certs_expiring = mysqli_fetch_assoc(mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT COUNT('certificate_id') as expiring_certs
|
||||
FROM certificates
|
||||
WHERE certificate_expire != '0000-00-00'
|
||||
AND certificate_expire > CURRENT_DATE
|
||||
AND certificate_expire < CURRENT_DATE + INTERVAL 30 DAY
|
||||
AND certificate_archived_at IS NULL
|
||||
AND company_id = $session_company_id"
|
||||
));
|
||||
$expiring_certificates = $sql_certs_expiring['expiring_certs'];
|
||||
|
||||
?>
|
||||
|
||||
<form class="mb-3">
|
||||
<select onchange="this.form.submit()" class="form-control" name="year">
|
||||
<?php
|
||||
|
||||
while ($row = mysqli_fetch_array($sql_payment_years)) {
|
||||
$payment_year = $row['all_years'];
|
||||
if (empty($payment_year)) {
|
||||
$payment_year = date('Y');
|
||||
}
|
||||
?>
|
||||
<option <?php if ($year == $payment_year) { echo "selected"; } ?> > <?php echo $payment_year; ?></option>
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
</select>
|
||||
</form>
|
||||
|
||||
<!-- Icon Cards-->
|
||||
<div class="row">
|
||||
|
||||
<div class="col-lg-4 col-6">
|
||||
<!-- small box -->
|
||||
<a class="small-box bg-secondary" href="clients.php?date_from=<?php echo $year; ?>-01-01&date_to=<?php echo $year; ?>-12-31">
|
||||
<div class="inner">
|
||||
<h3><?php echo $clients_added; ?></h3>
|
||||
<p>New Clients</p>
|
||||
</div>
|
||||
<div class="icon">
|
||||
<i class="fa fa-users"></i>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<!-- ./col -->
|
||||
|
||||
<div class="col-lg-4 col-6">
|
||||
<a class="small-box bg-success">
|
||||
<div class="inner">
|
||||
<h3><?php echo $contacts_added; ?></h3>
|
||||
<p>New Contacts</p>
|
||||
</div>
|
||||
<div class="icon">
|
||||
<i class="fa fa-user"></i>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<!-- ./col -->
|
||||
|
||||
<div class="col-lg-4 col-6">
|
||||
<a class="small-box bg-info">
|
||||
<div class="inner">
|
||||
<h3><?php echo $assets_added; ?></h3>
|
||||
<p>New Assets</p>
|
||||
</div>
|
||||
<div class="icon">
|
||||
<i class="fa fa-desktop"></i>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<!-- ./col -->
|
||||
|
||||
<div class="col-lg-4 col-6">
|
||||
<a class="small-box bg-danger" href="tickets.php">
|
||||
<div class="inner">
|
||||
<h3><?php echo $active_tickets; ?></h3>
|
||||
<p>Active Tickets</p>
|
||||
</div>
|
||||
<div class="icon">
|
||||
<i class="fa fa-ticket-alt"></i>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<!-- ./col -->
|
||||
|
||||
<div class="col-lg-4 col-6">
|
||||
<a class="small-box bg-warning">
|
||||
<div class="inner">
|
||||
<h3><?php echo $expiring_domains; ?></h3>
|
||||
<p>Expiring Domains</p>
|
||||
</div>
|
||||
<div class="icon">
|
||||
<i class="fa fa-globe"></i>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<!-- ./col -->
|
||||
|
||||
<div class="col-lg-4 col-6">
|
||||
<a class="small-box bg-primary">
|
||||
<div class="inner">
|
||||
<h3><?php echo $expiring_certificates; ?></h3>
|
||||
<p>Expiring Certificates</p>
|
||||
</div>
|
||||
<div class="icon">
|
||||
<i class="fa fa-lock"></i>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
<!-- ./col -->
|
||||
|
||||
</div> <!-- rows -->
|
||||
|
||||
<?php
|
||||
require_once("footer.php");
|
||||
|
||||
|
|
@ -353,7 +353,7 @@ function getDomainExpirationDate($name) {
|
|||
|
||||
// Only run if we think the domain is valid
|
||||
if (!filter_var($name, FILTER_VALIDATE_DOMAIN, FILTER_FLAG_HOSTNAME)) {
|
||||
return '0000-00-00';
|
||||
return "NULL";
|
||||
}
|
||||
|
||||
$ch = curl_init();
|
||||
|
|
@ -373,7 +373,7 @@ function getDomainExpirationDate($name) {
|
|||
}
|
||||
|
||||
// Default return
|
||||
return '0000-00-00';
|
||||
return "NULL";
|
||||
}
|
||||
|
||||
// Get domain general info (whois + NS/A/MX records)
|
||||
|
|
|
|||
Loading…
Reference in New Issue