diff --git a/ajax.php b/ajax.php index 0ead3ee3..98003749 100644 --- a/ajax.php +++ b/ajax.php @@ -120,7 +120,7 @@ if (isset($_GET['merge_ticket_get_json_details'])) { } else { //Return ticket, client and contact details for the given ticket number $response = mysqli_fetch_array($sql); - + echo json_encode($response); } } @@ -308,6 +308,42 @@ if (isset($_GET['scheduled_ticket_get_json_details'])) { } +/* + * Looks up info for a given quote ID from the database, used to dynamically populate modal fields + */ +if (isset($_GET['quote_get_json_details'])) { + $quote_id = intval($_GET['quote_id']); + + // Get quote details + $quote_sql = mysqli_query( + $mysqli, + "SELECT * FROM quotes + LEFT JOIN clients ON quote_client_id = client_id + WHERE quote_id = $quote_id LIMIT 1" + ); + + while ($row = mysqli_fetch_array($quote_sql)) { + $response['quote'][] = $row; + } + + + // Get all income-related categories for quoting + $quote_created_at = $response['quote'][0]['quote_created_at']; + $category_sql = mysqli_query( + $mysqli, + "SELECT category_id, category_name FROM categories + WHERE category_type = 'Income' AND (category_archived_at > '$quote_created_at' OR category_archived_at IS NULL) + ORDER BY category_name" + ); + + while ($row = mysqli_fetch_array($category_sql)) { + $response['categories'][] = $row; + } + + echo json_encode($response); + +} + /* * Dynamic TOTP for client login page * When provided with a TOTP secret, returns a 6-digit code diff --git a/client_quotes.php b/client_quotes.php index 7157c4c5..c13e13fb 100644 --- a/client_quotes.php +++ b/client_quotes.php @@ -120,7 +120,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()")); + diff --git a/quote_edit_modal.php b/quote_edit_modal.php index d041eac0..cd0e13db 100644 --- a/quote_edit_modal.php +++ b/quote_edit_modal.php @@ -1,70 +1,58 @@ -