mirror of https://github.com/itflow-org/itflow
Reworked Accept and Declining quote with improved logic including invoiced status
This commit is contained in:
parent
2b2954aa6f
commit
d90c7e4664
|
|
@ -94,14 +94,17 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
|
|||
$category_id = $row['category_id'];
|
||||
$category_name = $row['category_name'];
|
||||
|
||||
//Set Badge color based off of quote status
|
||||
if($quote_status == "Sent"){
|
||||
$quote_badge_color = "warning";
|
||||
$quote_badge_color = "warning text-white";
|
||||
}elseif($quote_status == "Viewed"){
|
||||
$quote_badge_color = "primary";
|
||||
}elseif($quote_status == "Approved"){
|
||||
}elseif($quote_status == "Accepted"){
|
||||
$quote_badge_color = "success";
|
||||
}elseif($quote_status == "Rejected"){
|
||||
}elseif($quote_status == "Declined"){
|
||||
$quote_badge_color = "danger";
|
||||
}elseif($quote_status == "Invoiced"){
|
||||
$quote_badge_color = "info";
|
||||
}else{
|
||||
$quote_badge_color = "secondary";
|
||||
}
|
||||
|
|
@ -125,13 +128,12 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
|
|||
<i class="fas fa-ellipsis-h"></i>
|
||||
</button>
|
||||
<div class="dropdown-menu">
|
||||
<a class="dropdown-item" href="post.php?email_quote=<?php echo $quote_id; ?>">Send</a>
|
||||
<a class="dropdown-item" href="post.php?approve_quote=<?php echo $quote_id; ?>">Approve</a>
|
||||
<a class="dropdown-item" href="post.php?pdf_quote=<?php echo $quote_id; ?>">PDF</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#editQuoteModal<?php echo $quote_id; ?>">Edit</a>
|
||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#addQuoteCopyModal<?php echo $quote_id; ?>">Copy</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item" href="post.php?email_quote=<?php echo $quote_id; ?>">Send</a>
|
||||
<a class="dropdown-item" href="post.php?pdf_quote=<?php echo $quote_id; ?>">PDF</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item" href="post.php?delete_quote=<?php echo $quote_id; ?>">Delete</a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -423,9 +423,9 @@ if(isset($_GET['pdf_quote'], $_GET['url_key'])){
|
|||
}
|
||||
}
|
||||
|
||||
if(isset($_GET['approve_quote'], $_GET['url_key'])){
|
||||
if(isset($_GET['accept_quote'], $_GET['url_key'])){
|
||||
|
||||
$quote_id = intval($_GET['approve_quote']);
|
||||
$quote_id = intval($_GET['accept_quote']);
|
||||
$url_key = mysqli_real_escape_string($mysqli,$_GET['url_key']);
|
||||
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM quotes
|
||||
|
|
@ -435,11 +435,11 @@ if(isset($_GET['approve_quote'], $_GET['url_key'])){
|
|||
|
||||
if(mysqli_num_rows($sql) == 1){
|
||||
|
||||
mysqli_query($mysqli,"UPDATE quotes SET quote_status = 'Approved' WHERE quote_id = $quote_id");
|
||||
mysqli_query($mysqli,"UPDATE quotes SET quote_status = 'Accepted' WHERE quote_id = $quote_id");
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = 'Approved', history_description = 'Client approved Quote!', history_created_at = NOW(), quote_id = $quote_id, company_id = $company_id");
|
||||
mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = 'Accepted', history_description = 'Client accepted Quote!', history_created_at = NOW(), quote_id = $quote_id, company_id = $company_id");
|
||||
|
||||
$_SESSION['alert_message'] = "Quote approved";
|
||||
$_SESSION['alert_message'] = "Quote Accepted";
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
}else{
|
||||
|
|
@ -448,9 +448,9 @@ if(isset($_GET['approve_quote'], $_GET['url_key'])){
|
|||
|
||||
}
|
||||
|
||||
if(isset($_GET['reject_quote'], $_GET['url_key'])){
|
||||
if(isset($_GET['decline_quote'], $_GET['url_key'])){
|
||||
|
||||
$quote_id = intval($_GET['reject_quote']);
|
||||
$quote_id = intval($_GET['decline_quote']);
|
||||
$url_key = mysqli_real_escape_string($mysqli,$_GET['url_key']);
|
||||
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM quotes
|
||||
|
|
@ -460,11 +460,11 @@ if(isset($_GET['reject_quote'], $_GET['url_key'])){
|
|||
|
||||
if(mysqli_num_rows($sql) == 1){
|
||||
|
||||
mysqli_query($mysqli,"UPDATE quotes SET quote_status = 'Rejected' WHERE quote_id = $quote_id");
|
||||
mysqli_query($mysqli,"UPDATE quotes SET quote_status = 'Declined' WHERE quote_id = $quote_id");
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = 'Rejected', history_description = 'Client rejected Quote!', history_created_at = NOW(), quote_id = $quote_id, company_id = $company_id");
|
||||
mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = 'Declined', history_description = 'Client declined Quote!', history_created_at = NOW(), quote_id = $quote_id, company_id = $company_id");
|
||||
|
||||
$_SESSION['alert_message'] = "Quote rejected";
|
||||
$_SESSION['alert_message'] = "Quote Declined";
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
}else{
|
||||
|
|
|
|||
|
|
@ -76,33 +76,23 @@ if(isset($_GET['quote_id'], $_GET['url_key'])){
|
|||
|
||||
mysqli_query($mysqli,"INSERT INTO alerts SET alert_type = 'Quote Viewed', alert_message = 'Quote $quote_number has been viewed by $client_name - $ip - $os - $browser - $device', alert_date = NOW(), company_id = $company_id");
|
||||
|
||||
//Set Badge color based off of quote status
|
||||
if($quote_status == "Sent"){
|
||||
$quote_badge_color = "warning text-white";
|
||||
}elseif($quote_status == "Viewed"){
|
||||
$quote_badge_color = "info";
|
||||
}elseif($quote_status == "Approved"){
|
||||
$quote_badge_color = "success";
|
||||
}elseif($quote_status == "Cancelled"){
|
||||
$quote_badge_color = "danger";
|
||||
}else{
|
||||
$quote_badge_color = "secondary";
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<div class="card">
|
||||
|
||||
<div class="card-header d-print-none">
|
||||
<div class="float-left">
|
||||
<?php
|
||||
if($quote_status == "Draft" or $quote_status == "Sent" or $quote_status == "Viewed"){
|
||||
?>
|
||||
<a class="btn btn-success" href="guest_post.php?accept_quote=<?php echo $quote_id; ?>&url_key=<?php echo $url_key; ?>"><i class="fa fa-fw fa-check"></i> Accept</a>
|
||||
<a class="btn btn-danger" href="guest_post.php?decline_quote=<?php echo $quote_id; ?>&url_key=<?php echo $url_key; ?>"><i class="fa fa-fw fa-times"></i> Decline</a>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<div class="float-right">
|
||||
<a class="btn btn-primary" href="#" onclick="window.print();"><i class="fa fa-fw fa-print"></i> Print</a>
|
||||
<a class="btn btn-primary" download target="_blank" href="guest_post.php?pdf_quote=<?php echo $quote_id; ?>&url_key=<?php echo $url_key; ?>"><i class="fa fa-fw fa-download"></i> Download</a>
|
||||
<?php
|
||||
if($quote_status == "Draft" or $quote_status == "Sent"){
|
||||
?>
|
||||
<a class="btn btn-success" href="guest_post.php?approve_quote=<?php echo $quote_id; ?>&url_key=<?php echo $url_key; ?>"><i class="fa fa-fw fa-thumbs-up"></i> Approve</a>
|
||||
<a class="btn btn-danger" href="guest_post.php?reject_quote=<?php echo $quote_id; ?>&url_key=<?php echo $url_key; ?>"><i class="fa fa-fw fa-thumbs-down"></i> Reject</a>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
|
|
|
|||
28
post.php
28
post.php
|
|
@ -1668,10 +1668,12 @@ if(isset($_POST['add_quote_to_invoice'])){
|
|||
mysqli_query($mysqli,"INSERT INTO invoice_items SET item_name = '$item_name', item_description = '$item_description', item_quantity = $item_quantity, item_price = '$item_price', item_subtotal = '$item_subtotal', item_tax = '$item_tax', item_total = '$item_total', item_created_at = NOW(), tax_id = $tax_id, invoice_id = $new_invoice_id, company_id = $session_company_id");
|
||||
}
|
||||
|
||||
mysqli_query($mysqli,"UPDATE quotes SET quote_status = 'Invoiced' WHERE quote_id = $quote_id AND company_id = $session_company_id");
|
||||
|
||||
//Logging
|
||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Quote', log_action = 'Created', log_description = 'Quote copied to Invoice', log_created_at = NOW(), company_id = $session_company_id, user_id = $session_user_id");
|
||||
|
||||
$_SESSION['alert_message'] = "Quoted copied to Invoice";
|
||||
$_SESSION['alert_message'] = "Quote copied to Invoice";
|
||||
|
||||
header("Location: invoice.php?invoice_id=$new_invoice_id");
|
||||
|
||||
|
|
@ -1860,35 +1862,35 @@ if(isset($_GET['mark_quote_sent'])){
|
|||
|
||||
}
|
||||
|
||||
if(isset($_GET['approve_quote'])){
|
||||
if(isset($_GET['accept_quote'])){
|
||||
|
||||
$quote_id = intval($_GET['approve_quote']);
|
||||
$quote_id = intval($_GET['accept_quote']);
|
||||
|
||||
mysqli_query($mysqli,"UPDATE quotes SET quote_status = 'Approved', quote_updated_at = NOW() WHERE quote_id = $quote_id AND company_id = $session_company_id");
|
||||
mysqli_query($mysqli,"UPDATE quotes SET quote_status = 'Accepted', quote_updated_at = NOW() WHERE quote_id = $quote_id AND company_id = $session_company_id");
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = 'Approved', history_description = 'Quote approved!', history_created_at = NOW(), quote_id = $quote_id, company_id = $session_company_id");
|
||||
mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = 'Accepted', history_description = 'Quote accepted!', history_created_at = NOW(), quote_id = $quote_id, company_id = $session_company_id");
|
||||
|
||||
//Logging
|
||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Quote', log_action = 'Modified', log_description = 'Approved Quote $quote_id', log_created_at = NOW(), company_id = $session_company_id, user_id = $session_user_id");
|
||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Quote', log_action = 'Modified', log_description = 'Accepted Quote $quote_id', log_created_at = NOW(), company_id = $session_company_id, user_id = $session_user_id");
|
||||
|
||||
$_SESSION['alert_message'] = "<i class='fa fa-2x fa-check-circle'></i> Quote approved";
|
||||
$_SESSION['alert_message'] = "<i class='fa fa-2x fa-check-circle'></i> Quote accepted";
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
|
||||
}
|
||||
|
||||
if(isset($_GET['reject_quote'])){
|
||||
if(isset($_GET['decline_quote'])){
|
||||
|
||||
$quote_id = intval($_GET['reject_quote']);
|
||||
$quote_id = intval($_GET['decline_quote']);
|
||||
|
||||
mysqli_query($mysqli,"UPDATE quotes SET quote_status = 'Rejected', quote_updated_at = NOW() WHERE quote_id = $quote_id AND company_id = $session_company_id");
|
||||
mysqli_query($mysqli,"UPDATE quotes SET quote_status = 'Declined', quote_updated_at = NOW() WHERE quote_id = $quote_id AND company_id = $session_company_id");
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = 'Cancelled', history_description = 'Quote rejected!', history_created_at = NOW(), quote_id = $quote_id, company_id = $session_company_id");
|
||||
mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = 'Cancelled', history_description = 'Quote declined!', history_created_at = NOW(), quote_id = $quote_id, company_id = $session_company_id");
|
||||
|
||||
//Logging
|
||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Quote', log_action = 'Modified', log_description = 'Rejected Quote $quote_id', log_created_at = NOW(), company_id = $session_company_id, user_id = $session_user_id");
|
||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Quote', log_action = 'Modified', log_description = 'Declined Quote $quote_id', log_created_at = NOW(), company_id = $session_company_id, user_id = $session_user_id");
|
||||
|
||||
$_SESSION['alert_message'] = "Quote rejected";
|
||||
$_SESSION['alert_message'] = "Quote declined";
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
|
||||
|
|
|
|||
24
quote.php
24
quote.php
|
|
@ -64,10 +64,12 @@ if(isset($_GET['quote_id'])){
|
|||
$quote_badge_color = "warning text-white";
|
||||
}elseif($quote_status == "Viewed"){
|
||||
$quote_badge_color = "primary";
|
||||
}elseif($quote_status == "Approved"){
|
||||
}elseif($quote_status == "Accepted"){
|
||||
$quote_badge_color = "success";
|
||||
}elseif($quote_status == "Cancelled"){
|
||||
}elseif($quote_status == "Declined"){
|
||||
$quote_badge_color = "danger";
|
||||
}elseif($quote_status == "Invoiced"){
|
||||
$quote_badge_color = "info";
|
||||
}else{
|
||||
$quote_badge_color = "secondary";
|
||||
}
|
||||
|
|
@ -103,17 +105,12 @@ if(isset($_GET['quote_id'])){
|
|||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<?php if($quote_status == 'Sent'){ ?>
|
||||
<button class="btn btn-success btn-sm dropdown-toggle" type="button" data-toggle="dropdown">
|
||||
<i class="fas fa-fw fa-check"></i> Approve/Reject
|
||||
</button>
|
||||
<div class="dropdown-menu">
|
||||
<a class="dropdown-item" href="post.php?approve_quote=<?php echo $quote_id; ?>">Approve</a>
|
||||
<a class="dropdown-item" href="post.php?reject_quote=<?php echo $quote_id; ?>">Reject</a>
|
||||
</div>
|
||||
<?php if($quote_status == 'Draft' or $quote_status == 'Sent' or $quote_status == 'Viewed'){ ?>
|
||||
<a class="btn btn-success" href="post.php?accept_quote=<?php echo $quote_id; ?>"><i class="fas fa-fw fa-check"></i> Accept</a>
|
||||
<a class="btn btn-danger" href="post.php?decline_quote=<?php echo $quote_id; ?>"><i class="fas fa-fw fa-times"></i> Decline</a>
|
||||
<?php } ?>
|
||||
|
||||
<?php if($quote_status == 'Approved'){ ?>
|
||||
<?php if($quote_status == 'Accepted'){ ?>
|
||||
<a class="btn btn-success btn-sm" href="#" data-toggle="modal" data-target="#addQuoteToInvoiceModal<?php echo $quote_id; ?>"><i class="fas fa-fw fa-check"></i> Invoice</a>
|
||||
<?php } ?>
|
||||
|
||||
|
|
@ -121,15 +118,16 @@ if(isset($_GET['quote_id'])){
|
|||
|
||||
<div class="col-md-8">
|
||||
<div class="dropdown dropleft text-center">
|
||||
<button class="btn btn-primary btn-sm float-right" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<button class="btn btn-primary btn-sm float-right" type="button" data-toggle="dropdown">
|
||||
<i class="fas fa-ellipsis-h"></i>
|
||||
</button>
|
||||
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
|
||||
<div class="dropdown-menu">
|
||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#editQuoteModal<?php echo $quote_id ?>">Edit</a>
|
||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#addQuoteCopyModal<?php echo $quote_id; ?>">Copy</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item" href="#" onclick="window.print();">Print</a>
|
||||
<a class="dropdown-item" href="post.php?pdf_quote=<?php echo $quote_id; ?>">PDF</a>
|
||||
<a class="dropdown-item" href="post.php?email_quote=<?php echo $quote_id; ?>">Send Email</a>
|
||||
<a class="dropdown-item" href="guest_view_quote.php?quote_id=<?php echo "$quote_id&url_key=$quote_url_key"; ?>">Guest URL</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item" href="#">Delete</a>
|
||||
|
|
|
|||
|
|
@ -142,6 +142,8 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
|
|||
$quote_badge_color = "success";
|
||||
}elseif($quote_status == "Rejected"){
|
||||
$quote_badge_color = "danger";
|
||||
}elseif($quote_status == "Invoiced"){
|
||||
$quote_badge_color = "info";
|
||||
}else{
|
||||
$quote_badge_color = "secondary";
|
||||
}
|
||||
|
|
@ -170,7 +172,6 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
|
|||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#addQuoteCopyModal<?php echo $quote_id; ?>">Copy</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item" href="post.php?email_quote=<?php echo $quote_id; ?>">Send</a>
|
||||
<a class="dropdown-item" href="post.php?approve_quote=<?php echo $quote_id; ?>">Approve</a>
|
||||
<a class="dropdown-item" href="post.php?pdf_quote=<?php echo $quote_id; ?>">PDF</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item" href="post.php?delete_quote=<?php echo $quote_id; ?>">Delete</a>
|
||||
|
|
|
|||
Loading…
Reference in New Issue