Added Expire Date field to Quotes also Do not show Guests Accept or Decline if Date is Expired

This commit is contained in:
johnnyq 2023-07-15 15:33:08 -04:00
parent 313191aeb2
commit e09c9cadb5
13 changed files with 90 additions and 11 deletions

View File

@ -60,6 +60,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
<th><a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=quote_scope&order=<?php echo $disp; ?>">Scope</a></th>
<th class="text-right"><a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=quote_amount&order=<?php echo $disp; ?>">Amount</a></th>
<th><a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=quote_date&order=<?php echo $disp; ?>">Date</a></th>
<th><a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=quote_expire&order=<?php echo $disp; ?>">Expire</a></th>
<th><a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=category_name&order=<?php echo $disp; ?>">Category</a></th>
<th><a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=quote_status&order=<?php echo $disp; ?>">Status</a></th>
<th class="text-center">Action</th>
@ -80,6 +81,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
}
$quote_status = nullable_htmlentities($row['quote_status']);
$quote_date = nullable_htmlentities($row['quote_date']);
$quote_expire = nullable_htmlentities($row['quote_expire']);
$quote_amount = floatval($row['quote_amount']);
$quote_currency_code = nullable_htmlentities($row['quote_currency_code']);
$quote_created_at = nullable_htmlentities($row['quote_created_at']);
@ -108,6 +110,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
<td><?php echo $quote_scope_display; ?></td>
<td class="text-right text-bold"><?php echo numfmt_format_currency($currency_format, $quote_amount, $quote_currency_code); ?></td>
<td><?php echo $quote_date; ?></td>
<td><?php echo $quote_expire; ?></td>
<td><?php echo $category_name; ?></td>
<td>
<span class="p-2 badge badge-<?php echo $quote_badge_color; ?>">

View File

@ -1150,11 +1150,17 @@ if (LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION) {
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.6.3'");
}
//if (CURRENT_DATABASE_VERSION == '0.6.3') {
//Insert queries here required to update to DB version 0.6.4
if (CURRENT_DATABASE_VERSION == '0.6.3') {
mysqli_query($mysqli, "ALTER TABLE `quotes` ADD COLUMN `quote_expire` DATE NULL DEFAULT NULL AFTER `quote_date`");
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.6.4'");
}
//if (CURRENT_DATABASE_VERSION == '0.6.4') {
//Insert queries here required to update to DB version 0.6.5
// Then, update the database to the next sequential version
//mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.6.4'");
//mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.6.5'");
//}
} else {

View File

@ -5,4 +5,4 @@
* It is used in conjunction with database_updates.php
*/
DEFINE("LATEST_DATABASE_VERSION", "0.6.3");
DEFINE("LATEST_DATABASE_VERSION", "0.6.4");

3
db.sql
View File

@ -871,6 +871,7 @@ CREATE TABLE `quotes` (
`quote_scope` varchar(255) DEFAULT NULL,
`quote_status` varchar(200) NOT NULL,
`quote_date` date NOT NULL,
`quote_expire` date DEFAULT NULL,
`quote_amount` decimal(15,2) NOT NULL DEFAULT 0.00,
`quote_currency_code` varchar(200) NOT NULL,
`quote_note` text DEFAULT NULL,
@ -1620,4 +1621,4 @@ CREATE TABLE `vendors` (
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2023-07-11 11:40:09
-- Dump completed on 2023-07-15 15:32:02

View File

@ -36,6 +36,7 @@ $quote_prefix = nullable_htmlentities($row['quote_prefix']);
$quote_number = intval($row['quote_number']);
$quote_status = nullable_htmlentities($row['quote_status']);
$quote_date = nullable_htmlentities($row['quote_date']);
$quote_expire = nullable_htmlentities($row['quote_expire']);
$quote_amount = floatval($row['quote_amount']);
$quote_currency_code = nullable_htmlentities($row['quote_currency_code']);
$quote_note = nullable_htmlentities($row['quote_note']);
@ -97,7 +98,7 @@ if ($quote_status == "Draft" || $quote_status == "Sent" || $quote_status == "Vie
<div class="card-header d-print-none">
<div class="float-left">
<?php
if ($quote_status == "Draft" || $quote_status == "Sent" || $quote_status == "Viewed") {
if ($quote_status == "Draft" || $quote_status == "Sent" || $quote_status == "Viewed" && strtotime($quote_expire) > strtotime("now")) {
?>
<a class="btn btn-success" href="guest_post.php?accept_quote=<?php echo $quote_id; ?>&url_key=<?php echo $url_key; ?>">
<i class="fas fa-fw fa-thumbs-up mr-2"></i>Accept
@ -161,6 +162,10 @@ if ($quote_status == "Draft" || $quote_status == "Sent" || $quote_status == "Vie
<td>Date</td>
<td class="text-right"><?php echo $quote_date; ?></td>
</tr>
<tr>
<td>Expire</td>
<td class="text-right"><?php echo $quote_expire; ?></td>
</tr>
</table>
</div>
</div>
@ -337,7 +342,7 @@ if ($quote_status == "Draft" || $quote_status == "Sent" || $quote_status == "Vie
[
{
text: '',
rowSpan: 2
rowSpan: 3
},
{},
{},
@ -353,6 +358,17 @@ if ($quote_status == "Draft" || $quote_status == "Sent" || $quote_status == "Vie
style: 'invoiceDateValue'
},
],
[
{},
{
text: 'Expire',
style: 'invoiceDateTitle'
},
{
text: <?php echo json_encode(html_entity_decode($quote_expire)) ?>,
style: 'invoiceDateValue'
},
],
]
}, // table
layout: 'lightHorizontalLines'

View File

@ -18,6 +18,7 @@ function populateQuoteEditModal(quote_id) {
document.getElementById("editQuoteHeaderClient").innerText = quote.client_name;
document.getElementById("editQuoteID").value = quote.quote_id;
document.getElementById("editQuoteDate").value = quote.quote_date;
document.getElementById("editQuoteExpire").value = quote.quote_expire;
document.getElementById("editQuoteScope").value = quote.quote_scope;
/* DROPDOWNS */

View File

@ -18,7 +18,7 @@ if (isset($_POST['add_quote'])) {
//Generate a unique URL key for clients to access
$quote_url_key = randomString(156);
mysqli_query($mysqli,"INSERT INTO quotes SET quote_prefix = '$config_quote_prefix', quote_number = $quote_number, quote_scope = '$scope', quote_date = '$date', quote_currency_code = '$session_company_currency', quote_category_id = $category, quote_status = 'Draft', quote_url_key = '$quote_url_key', quote_client_id = $client");
mysqli_query($mysqli,"INSERT INTO quotes SET quote_prefix = '$config_quote_prefix', quote_number = $quote_number, quote_scope = '$scope', quote_date = '$date', quote_expire = '$expire', quote_currency_code = '$session_company_currency', quote_category_id = $category, quote_status = 'Draft', quote_url_key = '$quote_url_key', quote_client_id = $client");
$quote_id = mysqli_insert_id($mysqli);
@ -37,6 +37,7 @@ if (isset($_POST['add_quote_copy'])) {
$quote_id = intval($_POST['quote_id']);
$date = sanitizeInput($_POST['date']);
$expire = sanitizeInput($_POST['expire']);
//Get the last Invoice Number and add 1 for the new invoice number
$quote_number = $config_quote_next_number;
@ -55,7 +56,7 @@ if (isset($_POST['add_quote_copy'])) {
//Generate a unique URL key for clients to access
$quote_url_key = randomString(156);
mysqli_query($mysqli,"INSERT INTO quotes SET quote_prefix = '$config_quote_prefix', quote_number = $quote_number, quote_scope = '$quote_scope', quote_date = '$date', quote_category_id = $category_id, quote_status = 'Draft', quote_amount = $quote_amount, quote_currency_code = '$quote_currency_code', quote_note = '$quote_note', quote_url_key = '$quote_url_key', quote_client_id = $client_id");
mysqli_query($mysqli,"INSERT INTO quotes SET quote_prefix = '$config_quote_prefix', quote_number = $quote_number, quote_scope = '$quote_scope', quote_date = '$date', quote_expire = '$expire', quote_category_id = $category_id, quote_status = 'Draft', quote_amount = $quote_amount, quote_currency_code = '$quote_currency_code', quote_note = '$quote_note', quote_url_key = '$quote_url_key', quote_client_id = $client_id");
$new_quote_id = mysqli_insert_id($mysqli);
@ -199,7 +200,7 @@ if (isset($_POST['edit_quote'])) {
$quote_id = intval($_POST['quote_id']);
mysqli_query($mysqli,"UPDATE quotes SET quote_scope = '$scope', quote_date = '$date', quote_category_id = $category WHERE quote_id = $quote_id");
mysqli_query($mysqli,"UPDATE quotes SET quote_scope = '$scope', quote_date = '$date', quote_expire = '$expire', quote_category_id = $category WHERE quote_id = $quote_id");
//Logging
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Quote', log_action = 'Modify', log_description = '$quote_id', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id");
@ -338,6 +339,7 @@ if (isset($_GET['email_quote'])) {
$quote_scope = $row['quote_scope'];
$quote_status = $row['quote_status'];
$quote_date = $row['quote_date'];
$quote_expire = $row['quote_expire'];
$quote_amount = floatval($row['quote_amount']);
$quote_url_key = $row['quote_url_key'];
$quote_currency_code = $row['quote_currency_code'];

View File

@ -1,4 +1,5 @@
<?php
$date = sanitizeInput($_POST['date']);
$expire = sanitizeInput($_POST['expire']);
$category = intval($_POST['category']);
$scope = sanitizeInput($_POST['scope']);

View File

@ -27,6 +27,7 @@ if (isset($_GET['quote_id'])) {
$quote_scope = nullable_htmlentities($row['quote_scope']);
$quote_status = nullable_htmlentities($row['quote_status']);
$quote_date = nullable_htmlentities($row['quote_date']);
$quote_expire = nullable_htmlentities($row['quote_expire']);
$quote_amount = floatval($row['quote_amount']);
$quote_currency_code = nullable_htmlentities($row['quote_currency_code']);
$quote_note = nullable_htmlentities($row['quote_note']);
@ -230,6 +231,10 @@ if (isset($_GET['quote_id'])) {
<td>Date</td>
<td class="text-right"><?php echo $quote_date; ?></td>
</tr>
<tr>
<td>Expire</td>
<td class="text-right"><?php echo $quote_expire; ?></td>
</tr>
</table>
</div>
</div>
@ -553,7 +558,7 @@ require_once("footer.php");
[
{
text: '',
rowSpan: 2
rowSpan: 3
},
{},
{},
@ -569,6 +574,17 @@ require_once("footer.php");
style: 'invoiceDateValue'
},
],
[
{},
{
text: 'Expire',
style: 'invoiceDateTitle'
},
{
text: <?php echo json_encode(html_entity_decode($quote_expire)) ?>,
style: 'invoiceDateValue'
},
],
]
}, // table
layout: 'lightHorizontalLines'

View File

@ -85,6 +85,16 @@
</div>
</div>
<div class="form-group">
<label>Expire <strong class="text-danger">*</strong></label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-calendar"></i></span>
</div>
<input type="date" class="form-control" name="expire" min="<?php echo date("Y-m-d"); ?>" max="2999-12-31" value="<?php echo date("Y-m-d", strtotime("+30 days")); ?>" required>
</div>
</div>
</div>
<div class="modal-footer bg-white">
<button type="submit" name="add_quote" class="btn btn-primary text-bold"><i class="fas fa-check mr-2"></i>Create</button>

View File

@ -21,6 +21,16 @@
</div>
</div>
<div class="form-group">
<label>Expire <strong class="text-danger">*</strong></label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-calendar"></i></span>
</div>
<input type="date" class="form-control" name="expire" min="<?php echo date("Y-m-d"); ?>" max="2999-12-31" value="<?php echo date("Y-m-d", strtotime("+30 days")); ?>" required>
</div>
</div>
</div>
<div class="modal-footer bg-white">
<button type="submit" name="add_quote_copy" class="btn btn-primary text-bold"><i class="fa fa-check mr-2"></i>Copy</button>

View File

@ -23,6 +23,16 @@
</div>
</div>
<div class="form-group">
<label>Expire <strong class="text-danger">*</strong></label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-calendar"></i></span>
</div>
<input type="date" class="form-control" name="expire" id="editQuoteExpire" max="2999-12-31" value="" required>
</div>
</div>
<div class="form-group">
<label>Income Category</label>
<div class="input-group">

View File

@ -86,6 +86,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
<th><a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=client_name&order=<?php echo $disp; ?>">Client</a></th>
<th class="text-right"><a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=quote_amount&order=<?php echo $disp; ?>">Amount</a></th>
<th><a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=quote_date&order=<?php echo $disp; ?>">Date</a></th>
<th><a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=quote_expire&order=<?php echo $disp; ?>">Expire</a></th>
<th><a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=category_name&order=<?php echo $disp; ?>">Category</a></th>
<th><a class="text-dark" href="?<?php echo $url_query_strings_sort; ?>&sort=quote_status&order=<?php echo $disp; ?>">Status</a></th>
<th class="text-center">Action</th>
@ -106,6 +107,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
}
$quote_status = nullable_htmlentities($row['quote_status']);
$quote_date = nullable_htmlentities($row['quote_date']);
$quote_expire = nullable_htmlentities($row['quote_expire']);
$quote_amount = floatval($row['quote_amount']);
$quote_currency_code = nullable_htmlentities($row['quote_currency_code']);
$quote_created_at = nullable_htmlentities($row['quote_created_at']);
@ -141,6 +143,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
<td class="text-bold"><a href="client_quotes.php?client_id=<?php echo $client_id; ?>"><?php echo $client_name; ?></a></td>
<td class="text-right text-bold"><?php echo numfmt_format_currency($currency_format, $quote_amount, $quote_currency_code); ?></td>
<td><?php echo $quote_date; ?></td>
<td><?php echo $quote_expire; ?></td>
<td><?php echo $category_name; ?></td>
<td>
<span class="p-2 badge badge-<?php echo $quote_badge_color; ?>">