mirror of https://github.com/itflow-org/itflow
Allow to Add Ticket to an exiting invoice item line
This commit is contained in:
parent
a837af6eb4
commit
fdf9d67910
19
post.php
19
post.php
|
|
@ -6371,6 +6371,7 @@ if(isset($_GET['close_ticket'])){
|
|||
|
||||
if(isset($_POST['add_invoice_from_ticket'])){
|
||||
|
||||
$invoice_id = intval($_POST['invoice_id']);
|
||||
$ticket_id = intval($_POST['ticket_id']);
|
||||
$date = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['date'])));
|
||||
$category = intval($_POST['category']);
|
||||
|
|
@ -6408,17 +6409,19 @@ if(isset($_POST['add_invoice_from_ticket'])){
|
|||
|
||||
$location_name = $row['location_name'];
|
||||
|
||||
if($invoice_id == 0){
|
||||
|
||||
//Get the last Invoice Number and add 1 for the new invoice number
|
||||
$invoice_number = $config_invoice_next_number;
|
||||
$new_config_invoice_next_number = $config_invoice_next_number + 1;
|
||||
mysqli_query($mysqli,"UPDATE settings SET config_invoice_next_number = $new_config_invoice_next_number WHERE company_id = $session_company_id");
|
||||
//Get the last Invoice Number and add 1 for the new invoice number
|
||||
$invoice_number = $config_invoice_next_number;
|
||||
$new_config_invoice_next_number = $config_invoice_next_number + 1;
|
||||
mysqli_query($mysqli,"UPDATE settings SET config_invoice_next_number = $new_config_invoice_next_number WHERE company_id = $session_company_id");
|
||||
|
||||
//Generate a unique URL key for clients to access
|
||||
$url_key = keygen();
|
||||
//Generate a unique URL key for clients to access
|
||||
$url_key = keygen();
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO invoices SET invoice_prefix = '$config_invoice_prefix', invoice_number = $invoice_number, invoice_scope = '$scope', invoice_date = '$date', invoice_due = DATE_ADD('$date', INTERVAL $client_net_terms day), invoice_currency_code = '$session_company_currency', invoice_category_id = $category, invoice_status = 'Draft', invoice_url_key = '$url_key', invoice_created_at = NOW(), invoice_client_id = $client_id, company_id = $session_company_id");
|
||||
$invoice_id = mysqli_insert_id($mysqli);
|
||||
mysqli_query($mysqli,"INSERT INTO invoices SET invoice_prefix = '$config_invoice_prefix', invoice_number = $invoice_number, invoice_scope = '$scope', invoice_date = '$date', invoice_due = DATE_ADD('$date', INTERVAL $client_net_terms day), invoice_currency_code = '$session_company_currency', invoice_category_id = $category, invoice_status = 'Draft', invoice_url_key = '$url_key', invoice_created_at = NOW(), invoice_client_id = $client_id, company_id = $session_company_id");
|
||||
$invoice_id = mysqli_insert_id($mysqli);
|
||||
}
|
||||
|
||||
//Add Item
|
||||
$item_name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['item_name'])));
|
||||
|
|
|
|||
|
|
@ -578,11 +578,11 @@ if(isset($_GET['ticket_id'])){
|
|||
|
||||
<div class="card card-body card-outline card-dark mb-2">
|
||||
<div class="">
|
||||
<a href="#" class="btn btn-outline-success btn-block" href="#" data-toggle="modal" data-target="#addInvoiceFromTicketModal">INVOICE</a>
|
||||
<a href="#" class="btn btn-outline-success btn-block" href="#" data-toggle="modal" data-target="#addInvoiceFromTicketModal">Invoice Ticket</a>
|
||||
<?php
|
||||
if($ticket_status !== "Closed"){
|
||||
?>
|
||||
<a href="post.php?close_ticket=<?php echo $ticket_id; ?>" class="btn btn-outline-danger btn-block">CLOSE TICKET</a>
|
||||
<a href="post.php?close_ticket=<?php echo $ticket_id; ?>" class="btn btn-outline-danger btn-block">Close Ticket</a>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -595,6 +595,7 @@ if(isset($_GET['ticket_id'])){
|
|||
include("ticket_edit_modal.php");
|
||||
include("ticket_merge_modal.php");
|
||||
include("ticket_invoice_add_modal.php");
|
||||
include("ticket_invoice_existing_add_modal.php");
|
||||
?>
|
||||
|
||||
<?php
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<div class="modal-dialog">
|
||||
<div class="modal-content bg-dark">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title"><i class="fa fa-fw fa-file"></i> New Invoice from Ticket</h5>
|
||||
<h5 class="modal-title"><i class="fa fa-fw fa-file"></i> Invoice Ticket</h5>
|
||||
<button type="button" class="close text-white" data-dismiss="modal">
|
||||
<span>×</span>
|
||||
</button>
|
||||
|
|
@ -13,6 +13,37 @@
|
|||
|
||||
<input type="hidden" name="ticket_id" value="<?php echo $ticket_id; ?>">
|
||||
|
||||
<div class="form-group">
|
||||
<label>Exisiting Invoice?</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-file-invoice-dollar"></i></span>
|
||||
</div>
|
||||
<select class="form-control select2" name="invoice_id">
|
||||
<option value="0">New Invoice</option>
|
||||
<?php
|
||||
|
||||
$sql_invoices = mysqli_query($mysqli,"SELECT * FROM invoices WHERE invoice_status NOT LIKE 'Paid' AND invoice_client_id = $client_id AND company_id = $session_company_id ORDER BY invoice_number ASC");
|
||||
while($row = mysqli_fetch_array($sql_invoices)){
|
||||
$invoice_id = $row['invoice_id'];
|
||||
$invoice_prefix = $row['invoice_prefix'];
|
||||
$invoice_number = $row['invoice_number'];
|
||||
$invoice_scope = $row['invoice_scope'];
|
||||
$invoice_satus = $row['invoice_status'];
|
||||
$invoice_date = $row['invoice_date'];
|
||||
$invoice_due = $row['invoice_due'];
|
||||
$invoice_amount = $row['invoice_amount'];
|
||||
|
||||
?>
|
||||
<option value="<?php echo $invoice_id; ?>"><?php echo "$invoice_prefix$invoice_number $invoice_scope"; ?></option>
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Invoice Date <strong class="text-danger">*</strong></label>
|
||||
<div class="input-group">
|
||||
|
|
|
|||
Loading…
Reference in New Issue