diff --git a/.github/workflows/dbsql-lint.yml b/.github/workflows/dbsql-lint.yml new file mode 100644 index 000000000..d190fd300 --- /dev/null +++ b/.github/workflows/dbsql-lint.yml @@ -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;" diff --git a/ajax.php b/ajax.php index 8875fb597..41467ac59 100644 --- a/ajax.php +++ b/ajax.php @@ -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 @@ -368,7 +369,7 @@ $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"); @@ -376,11 +377,26 @@ $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); } @@ -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)) { diff --git a/client_assets.php b/client_assets.php index fb963d7e1..cf0881f89 100644 --- a/client_assets.php +++ b/client_assets.php @@ -109,26 +109,26 @@
+
+
+
+