Skip to content

Commit

Permalink
Merge branch 'master' into 0.2.0.0-functionalizing
Browse files Browse the repository at this point in the history
  • Loading branch information
o-psi authored Mar 20, 2024
2 parents 8bd6531 + 643144b commit 53b192d
Show file tree
Hide file tree
Showing 34 changed files with 887 additions and 425 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/dbsql-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: SQL Syntax Check for db.sql

on:
pull_request:
paths:
- 'db.sql'

jobs:
syntax_check:
name: Check db.sql SQL Syntax
runs-on: ubuntu-latest

services:
mariadb:
image: mariadb:latest
ports:
- "3306:3306"
env:
MYSQL_RANDOM_ROOT_PASSWORD: "yes"
MARIADB_USER: user
MARIADB_PASSWORD: password
MARIADB_DATABASE: itfsyntaxdb
options: >-
--health-cmd="healthcheck.sh --connect --innodb_initialized"
--health-interval=10s
--health-timeout=5s
--health-retries=3
steps:
- name: Checkout Repository
uses: actions/checkout@v3

- name: Import & Lint db.sql
run: mysql --host 127.0.0.1 -uuser -ppassword itfsyntaxdb < db.sql

- name: Show imported tables
run: mysql --host 127.0.0.1 -uuser -ppassword itfsyntaxdb -e "show tables;"
22 changes: 19 additions & 3 deletions ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,7 @@
$client_id = intval($_GET['client_id']);
$ticket_id = intval($_GET['ticket_id']);

// Get all contacts, to allow tickets to be raised under a specific contact
$contact_sql = mysqli_query($mysqli, "SELECT contact_id, contact_name FROM contacts
WHERE contact_client_id = $client_id
AND contact_archived_at IS NULL
Expand All @@ -368,19 +369,34 @@
$response['contacts'][] = $row;
}


// Get ticket details
$ticket_sql = mysqli_query($mysqli, "SELECT * FROM scheduled_tickets
WHERE scheduled_ticket_id = $ticket_id
AND scheduled_ticket_client_id = $client_id LIMIT 1");
while ($row = mysqli_fetch_array($ticket_sql)) {
$response['ticket'][] = $row;
}

// Get assets
$asset_sql = mysqli_query($mysqli, "SELECT asset_id, asset_name FROM assets WHERE asset_client_id = $client_id AND asset_archived_at IS NULL");
while ($row = mysqli_fetch_array($asset_sql)) {
$response['assets'][] = $row;
}

// Get technicians to auto assign the ticket to
$sql_agents = mysqli_query(
$mysqli,
"SELECT users.user_id, user_name FROM users
LEFT JOIN user_settings on users.user_id = user_settings.user_id
WHERE user_role > 1
AND user_status = 1
AND user_archived_at IS NULL
ORDER BY user_name ASC"
);
while ($row = mysqli_fetch_array($sql_agents)) {
$response['agents'][] = $row;
}

echo json_encode($response);

}
Expand Down Expand Up @@ -448,9 +464,9 @@

$contact_sql = mysqli_query(
$mysqli,
"SELECT contact_id, contact_name FROM contacts
"SELECT contact_id, contact_name, contact_primary, contact_important, contact_technical FROM contacts
WHERE contacts.contact_archived_at IS NULL AND contact_client_id = $client_id
ORDER BY contact_important DESC, contact_name"
ORDER BY contact_primary DESC, contact_technical DESC, contact_important DESC, contact_name"
);

while ($row = mysqli_fetch_array($contact_sql)) {
Expand Down
198 changes: 102 additions & 96 deletions client_assets.php

Large diffs are not rendered by default.

29 changes: 13 additions & 16 deletions client_contact_details.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,12 @@
<td><?php echo $asset_type; ?></td>
<td>
<?php echo $asset_make; ?>
<div class="mt-0">
<div class="mt-0">
<small class="text-muted"><?php echo $asset_model; ?></small>
</div>
</td>
<td><?php echo $asset_serial_display; ?></td>

<td><?php echo $asset_install_date_display; ?></td>
<td><?php echo $asset_status; ?></td>
<td>
Expand Down Expand Up @@ -580,26 +580,23 @@ function updateContactNotes(contact_id) {
<script>

function generatePassword(type, id) {
var url = '/ajax.php?get_readable_pass=true';

// Make an AJAX request to the server
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);

xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
var password = xhr.responseText;

// Set the password value based on the type
// Send a GET request to ajax.php as ajax.php?get_readable_pass=true
jQuery.get(
"ajax.php", {
get_readable_pass: 'true'
},
function(data) {
//If we get a response from post.php, parse it as JSON
const password = JSON.parse(data);

// Set the password value to the correct modal, based on the type
if (type == "add") {
document.getElementById("password-add").value = password;
} else if (type == "edit") {
console.log("password-edit-"+id.toString());
document.getElementById("password-edit-"+id.toString()).value = password;
}
}
};
xhr.send();
);
}

$(document).ready(function() {
Expand Down
68 changes: 34 additions & 34 deletions client_contacts.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
<input class="form-check-input" id="selectAllCheckbox" type="checkbox" onclick="checkAll(this)">
</div>
</td>
<th class="text-center px-0"><a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=contact_name&order=<?php echo $disp; ?>">Name</a></th>
<th><a class="text-secondary ml-3" href="?<?php echo $url_query_strings_sort; ?>&sort=contact_name&order=<?php echo $disp; ?>">Name</a></th>
<th><a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=contact_department&order=<?php echo $disp; ?>">Department</a></th>
<th>Contact</th>
<th><a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=location_name&order=<?php echo $disp; ?>">Location</a></th>
Expand All @@ -121,13 +121,13 @@
$contact_name = nullable_htmlentities($row['contact_name']);
$contact_title = nullable_htmlentities($row['contact_title']);
if (empty($contact_title)) {
$contact_title_display = "-";
$contact_title_display = "";
} else {
$contact_title_display = "<small class='text-secondary'>$contact_title</small>";
}
$contact_department = nullable_htmlentities($row['contact_department']);
if (empty($contact_department)) {
$contact_department_display = "";
$contact_department_display = "-";
} else {
$contact_department_display = $contact_department;
}
Expand Down Expand Up @@ -210,28 +210,31 @@
<input class="form-check-input bulk-select" type="checkbox" name="contact_ids[]" value="<?php echo $contact_id ?>">
</div>
</td>
<td class="px-0 text-center <?php if(!empty($contact_important)) { echo "text-bold"; }?>">
<td>
<a class="text-dark" href="client_contact_details.php?client_id=<?php echo $client_id; ?>&contact_id=<?php echo $contact_id; ?>">
<?php if (!empty($contact_photo)) { ?>

<img class="img-size-50 img-circle" src="<?php echo "uploads/clients/$client_id/$contact_photo"; ?>">

<?php } else { ?>
<div class="media">
<?php if (!empty($contact_photo)) { ?>
<span class="fa-stack fa-2x mr-3 text-center">
<img class="img-size-50 img-circle" src="<?php echo "uploads/clients/$client_id/$contact_photo"; ?>">
</span>
<?php } else { ?>

<span class="fa-stack fa-2x mr-3">
<i class="fa fa-circle fa-stack-2x text-secondary"></i>
<span class="fa fa-stack-1x text-white"><?php echo $contact_initials; ?></span>
</span>

<span class="fa-stack fa-2x">
<i class="fa fa-circle fa-stack-2x text-secondary"></i>
<span class="fa fa-stack-1x text-white"><?php echo $contact_initials; ?></span>
</span>

<br>
<?php } ?>

<?php } ?>
<div class="text-dark"><?php echo $contact_name; ?></div>
<div><?php echo $contact_title_display; ?></div>
<div><?php echo $contact_primary_display; ?></div>
<div class="media-body">
<div class="<?php if(!empty($contact_important)) { echo "text-bold"; } ?>"><?php echo $contact_name; ?></div>
<?php echo $contact_title_display; ?>
<div><?php echo $contact_primary_display; ?></div>

</div>
</div>
</a>
</td>

<td><?php echo $contact_department_display; ?></td>
<td><?php echo $contact_info_display; ?></td>
<td><?php echo $location_name_display; ?></td>
Expand Down Expand Up @@ -293,26 +296,23 @@
<script>

function generatePassword(type, id) {
var url = '/ajax.php?get_readable_pass=true';

// Make an AJAX request to the server
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);

xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200) {
var password = xhr.responseText;

// Set the password value based on the type
// Send a GET request to ajax.php as ajax.php?get_readable_pass=true
jQuery.get(
"ajax.php", {
get_readable_pass: 'true'
},
function(data) {
//If we get a response from post.php, parse it as JSON
const password = JSON.parse(data);

// Set the password value to the correct modal, based on the type
if (type == "add") {
document.getElementById("password-add").value = password;
} else if (type == "edit") {
console.log("password-edit-"+id.toString());
document.getElementById("password-edit-"+id.toString()).value = password;
}
}
};
xhr.send();
);
}

$(document).ready(function() {
Expand Down
12 changes: 12 additions & 0 deletions client_file_upload_modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,19 @@
<input type="hidden" name="client_id" value="<?php echo $client_id; ?>">
<div class="modal-body bg-white">


<div class="form-group">
<label>Description</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-angle-right"></i></span>
</div>
<input type="text" class="form-control" name="description" placeholder="Description of the file">
</div>
</div>

<div class="form-group mb-4">
<label>Folder</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-folder"></i></span>
Expand Down
19 changes: 17 additions & 2 deletions client_files.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
WHERE file_client_id = $client_id
AND file_folder_id = $folder_id
AND file_archived_at IS NULL
AND (file_name LIKE '%$q%' OR file_ext LIKE '%$q%')
AND (file_name LIKE '%$q%' OR file_ext LIKE '%$q%' OR file_description LIKE '%$q%')
$query_images
ORDER BY $sort $order LIMIT $record_from, $record_to"
);
Expand Down Expand Up @@ -147,6 +147,7 @@
<form autocomplete="off">
<input type="hidden" name="client_id" value="<?php echo $client_id; ?>">
<input type="hidden" name="view" value="<?php echo $view; ?>">
<input type="hidden" name="folder_id" value="<?php echo $get_folder_id; ?>">
<div class="row">
<div class="col-md-4">
<div class="input-group mb-3 mb-md-0">
Expand Down Expand Up @@ -249,6 +250,7 @@
while ($row = mysqli_fetch_array($sql)) {
$file_id = intval($row['file_id']);
$file_name = nullable_htmlentities($row['file_name']);
$file_description = nullable_htmlentities($row['file_description']);
$file_reference_name = nullable_htmlentities($row['file_reference_name']);
$file_ext = nullable_htmlentities($row['file_ext']);
if ($file_ext == 'pdf') {
Expand Down Expand Up @@ -283,7 +285,20 @@
<input class="form-check-input bulk-select" type="checkbox" name="file_ids[]" value="<?php echo $file_id ?>">
</div>
</td>
<td><a href="<?php echo "uploads/clients/$client_id/$file_reference_name"; ?>" target="_blank" class="text-secondary"><i class="fa fa-fw fa-2x fa-<?php echo $file_icon; ?> mr-3"></i> <?php echo basename($file_name); ?></a></td>
<td>
<a href="<?php echo "uploads/clients/$client_id/$file_reference_name"; ?>" target="_blank" class="text-secondary">
<div class="media">
<i class="fa fa-fw fa-2x fa-<?php echo $file_icon; ?> mr-3"></i>
<div class="media-body">
<p>
<?php echo basename($file_name); ?>
<br>
<small class="text-secondary"><?php echo $file_description; ?></small>
</p>
</div>
</div>
</a>
</td>
<td><?php echo $file_created_at; ?></td>
<td>
<div class="dropdown dropleft text-center">
Expand Down
33 changes: 28 additions & 5 deletions client_location_add_modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,25 @@

<ul class="nav nav-pills nav-justified mb-3">
<li class="nav-item">
<a class="nav-link active" data-toggle="pill" href="#pills-address">Address</a>
<a class="nav-link active" data-toggle="pill" href="#pills-details">Details</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="pill" href="#pills-address">Address</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="pill" href="#pills-contact">Contact</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="pill" href="#pills-photo">Photo</a>
<a class="nav-link" data-toggle="pill" href="#pills-notes">Notes</a>
</li>

</ul>

<hr>

<div class="tab-content">

<div class="tab-pane fade show active" id="pills-address">
<div class="tab-pane fade show active" id="pills-details">

<div class="form-group">
<label>Location Name <strong class="text-danger">*</strong> / <span class="text-secondary">Primary</span></label>
Expand All @@ -44,6 +48,25 @@
</div>
</div>

<div class="form-group">
<label>Description</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-angle-right"></i></span>
</div>
<input type="text" class="form-control" name="description" placeholder="Short Description">
</div>
</div>

<div class="form-group">
<label>Photo</label>
<input type="file" class="form-control-file" name="file">
</div>

</div>

<div class="tab-pane fade" id="pills-address">

<div class="form-group">
<label>Address</label>
<div class="input-group">
Expand Down Expand Up @@ -151,10 +174,10 @@

</div>

<div class="tab-pane fade" id="pills-photo">
<div class="tab-pane fade" id="pills-notes">

<div class="form-group">
<input type="file" class="form-control-file" name="file">
<textarea class="form-control" rows="12" name="notes" placeholder="Notes, eg Parking Info, Building Access etc"></textarea>
</div>

</div>
Expand Down
Loading

0 comments on commit 53b192d

Please sign in to comment.