mirror of https://github.com/itflow-org/itflow
Rename table invoice_payments to just payments added per client net terms dumped new SQL DB Structure
This commit is contained in:
parent
0fc29c0271
commit
513648aa59
|
|
@ -63,15 +63,31 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Website</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-globe"></i></span>
|
||||
<div class="form-row">
|
||||
<div class="form-group col">
|
||||
<label>Website</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-globe"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="website" placeholder="Web Address">
|
||||
</div>
|
||||
<input type="text" class="form-control" name="website" placeholder="Web Address">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group col">
|
||||
<label>Invoice Net Terms</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-clock"></i></span>
|
||||
</div>
|
||||
<select class="form-control" name="net_terms">
|
||||
<option value="7">Default (7 Days)</option>
|
||||
<option value="1">Upon Reciept</option>
|
||||
<option value="14">14 Day</option>
|
||||
<option value="30">30 Day</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<div class="modal fade" id="addInvoicePaymentModal" tabindex="-1">
|
||||
<div class="modal fade" id="addPaymentModal" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
|
|
@ -80,7 +80,7 @@
|
|||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
|
||||
<button type="submit" name="add_invoice_payment" class="btn btn-primary">Save</button>
|
||||
<button type="submit" name="add_payment" class="btn btn-primary">Save</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
|
@ -19,6 +19,7 @@ if(isset($_GET['client_id'])){
|
|||
$client_phone = substr($row['client_phone'],0,3)."-".substr($row['client_phone'],3,3)."-".substr($row['client_phone'],6,4);
|
||||
}
|
||||
$client_website = $row['client_website'];
|
||||
$client_net_terms = $row['client_net_terms'];
|
||||
|
||||
//Badge Counts
|
||||
|
||||
|
|
|
|||
52
db.sql
52
db.sql
|
|
@ -100,6 +100,7 @@ CREATE TABLE `client_contacts` (
|
|||
`client_contact_phone` varchar(200) NOT NULL,
|
||||
`client_contact_primary` tinyint(1) NOT NULL,
|
||||
`client_contact_recieve_invoices` tinyint(1) NOT NULL,
|
||||
`location_id` int(11) NOT NULL,
|
||||
`client_id` int(11) NOT NULL,
|
||||
PRIMARY KEY (`client_contact_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8mb4;
|
||||
|
|
@ -234,6 +235,7 @@ CREATE TABLE `clients` (
|
|||
`client_phone` varchar(200) NOT NULL,
|
||||
`client_email` varchar(200) NOT NULL,
|
||||
`client_website` varchar(200) NOT NULL,
|
||||
`client_net_terms` int(10) NOT NULL,
|
||||
`client_created_at` int(11) NOT NULL,
|
||||
`client_updated_at` int(11) NOT NULL,
|
||||
PRIMARY KEY (`client_id`)
|
||||
|
|
@ -256,7 +258,7 @@ CREATE TABLE `expenses` (
|
|||
`category_id` int(11) NOT NULL,
|
||||
`account_id` int(11) NOT NULL,
|
||||
PRIMARY KEY (`expense_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4;
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
|
|
@ -273,7 +275,7 @@ CREATE TABLE `invoice_history` (
|
|||
`invoice_history_description` varchar(200) NOT NULL,
|
||||
`invoice_id` int(11) NOT NULL,
|
||||
PRIMARY KEY (`invoice_history_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8mb4;
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=utf8mb4;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
|
|
@ -294,26 +296,7 @@ CREATE TABLE `invoice_items` (
|
|||
`invoice_item_total` decimal(15,2) NOT NULL,
|
||||
`invoice_id` int(11) NOT NULL,
|
||||
PRIMARY KEY (`invoice_item_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `invoice_payments`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `invoice_payments`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `invoice_payments` (
|
||||
`invoice_payment_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`invoice_payment_date` date NOT NULL,
|
||||
`invoice_payment_amount` decimal(15,2) NOT NULL,
|
||||
`invoice_payment_method` varchar(200) NOT NULL,
|
||||
`invoice_payment_reference` varchar(200) NOT NULL,
|
||||
`account_id` int(11) NOT NULL,
|
||||
`invoice_id` int(11) NOT NULL,
|
||||
PRIMARY KEY (`invoice_payment_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=28 DEFAULT CHARSET=utf8mb4;
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
|
|
@ -330,11 +313,11 @@ CREATE TABLE `invoices` (
|
|||
`invoice_date` date NOT NULL,
|
||||
`invoice_due` date NOT NULL,
|
||||
`invoice_amount` decimal(15,2) NOT NULL,
|
||||
`invoice_notes` text NOT NULL,
|
||||
`invoice_note` text NOT NULL,
|
||||
`category_id` int(11) NOT NULL,
|
||||
`client_id` int(11) NOT NULL,
|
||||
PRIMARY KEY (`invoice_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4;
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
|
|
@ -358,6 +341,25 @@ CREATE TABLE `mileage` (
|
|||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `payments`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `payments`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `payments` (
|
||||
`payment_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`payment_date` date NOT NULL,
|
||||
`payment_amount` decimal(15,2) NOT NULL,
|
||||
`payment_method` varchar(200) NOT NULL,
|
||||
`payment_reference` varchar(200) NOT NULL,
|
||||
`account_id` int(11) NOT NULL,
|
||||
`invoice_id` int(11) NOT NULL,
|
||||
PRIMARY KEY (`payment_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=19 DEFAULT CHARSET=utf8mb4;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `transfers`
|
||||
--
|
||||
|
|
@ -419,4 +421,4 @@ CREATE TABLE `vendors` (
|
|||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||
|
||||
-- Dump completed on 2019-03-31 16:33:55
|
||||
-- Dump completed on 2019-04-07 12:36:00
|
||||
|
|
|
|||
20
invoice.php
20
invoice.php
|
|
@ -35,10 +35,10 @@ if(isset($_GET['invoice_id'])){
|
|||
|
||||
$sql_invoice_history = mysqli_query($mysqli,"SELECT * FROM invoice_history WHERE invoice_id = $invoice_id ORDER BY invoice_history_id ASC");
|
||||
|
||||
$sql_payments = mysqli_query($mysqli,"SELECT * FROM invoice_payments, accounts WHERE invoice_payments.account_id = accounts.account_id AND invoice_payments.invoice_id = $invoice_id ORDER BY invoice_payments.invoice_payment_id DESC");
|
||||
$sql_payments = mysqli_query($mysqli,"SELECT * FROM payments, accounts WHERE payments.account_id = accounts.account_id AND payments.invoice_id = $invoice_id ORDER BY payments.payment_id DESC");
|
||||
|
||||
//Add up all the payments for the invoice and get the total amount paid to the invoice
|
||||
$sql_amount_paid = mysqli_query($mysqli,"SELECT SUM(invoice_payment_amount) AS amount_paid FROM invoice_payments WHERE invoice_id = $invoice_id");
|
||||
$sql_amount_paid = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS amount_paid FROM payments WHERE invoice_id = $invoice_id");
|
||||
$row = mysqli_fetch_array($sql_amount_paid);
|
||||
$amount_paid = $row['amount_paid'];
|
||||
|
||||
|
|
@ -89,7 +89,7 @@ if(isset($_GET['invoice_id'])){
|
|||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#addinvoiceCopyModal<?php echo $invoice_id; ?>">Copy</a>
|
||||
<a class="dropdown-item" href="email_invoice.php?invoice_id=<?php echo $invoice_id; ?>">Send Email</a>
|
||||
<?php if($invoice_status == "Draft"){ ?><a class="dropdown-item" href="post.php?mark_invoice_sent=<?php echo $invoice_id; ?>">Mark Sent</a><?php } ?>
|
||||
<?php if($invoice_status !== "Paid"){ ?><a class="dropdown-item" href="#" data-toggle="modal" data-target="#addInvoicePaymentModal">Add Payment</a><?php } ?>
|
||||
<?php if($invoice_status !== "Paid"){ ?><a class="dropdown-item" href="#" data-toggle="modal" data-target="#addPaymentModal">Add Payment</a><?php } ?>
|
||||
<a class="dropdown-item" href="#" onclick="window.print();">Print</a>
|
||||
<a class="dropdown-item" href="#">Delete</a>
|
||||
</div>
|
||||
|
|
@ -319,18 +319,18 @@ if(isset($_GET['invoice_id'])){
|
|||
<?php
|
||||
|
||||
while($row = mysqli_fetch_array($sql_payments)){
|
||||
$invoice_payment_id = $row['invoice_payment_id'];
|
||||
$invoice_payment_date = $row['invoice_payment_date'];
|
||||
$invoice_payment_amount = $row['invoice_payment_amount'];
|
||||
$payment_id = $row['payment_id'];
|
||||
$payment_date = $row['payment_date'];
|
||||
$payment_amount = $row['payment_amount'];
|
||||
$account_name = $row['account_name'];
|
||||
|
||||
|
||||
?>
|
||||
<tr>
|
||||
<td><?php echo $invoice_payment_date; ?></td>
|
||||
<td>$<?php echo number_format($invoice_payment_amount,2); ?></td>
|
||||
<td><?php echo $payment_date; ?></td>
|
||||
<td>$<?php echo number_format($payment_amount,2); ?></td>
|
||||
<td><?php echo $account_name; ?></td>
|
||||
<td class="text-center"><a class="btn btn-danger btn-sm" href="post.php?delete_invoice_payment=<?php echo $invoice_payment_id; ?>"><i class="fa fa-trash"></i></a></td>
|
||||
<td class="text-center"><a class="btn btn-danger btn-sm" href="post.php?delete_payment=<?php echo $payment_id; ?>"><i class="fa fa-trash"></i></a></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
|
@ -342,7 +342,7 @@ if(isset($_GET['invoice_id'])){
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<?php include("add_invoice_payment_modal.php"); ?>
|
||||
<?php include("add_payment_modal.php"); ?>
|
||||
<?php include("edit_invoice_modal.php"); ?>
|
||||
<?php include("edit_invoice_note_modal.php"); ?>
|
||||
<?php } ?>
|
||||
|
|
|
|||
49
post.php
49
post.php
|
|
@ -75,8 +75,9 @@ if(isset($_POST['add_client'])){
|
|||
$phone = preg_replace("/[^0-9]/", '',$phone);
|
||||
$email = strip_tags(mysqli_real_escape_string($mysqli,$_POST['email']));
|
||||
$website = strip_tags(mysqli_real_escape_string($mysqli,$_POST['website']));
|
||||
$net_terms = intval($_POST['net_terms']);
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO clients SET client_name = '$name', client_address = '$address', client_city = '$city', client_state = '$state', client_zip = '$zip', client_phone = '$phone', client_email = '$email', client_website = '$website', client_created_at = UNIX_TIMESTAMP()");
|
||||
mysqli_query($mysqli,"INSERT INTO clients SET client_name = '$name', client_address = '$address', client_city = '$city', client_state = '$state', client_zip = '$zip', client_phone = '$phone', client_email = '$email', client_website = '$website', client_net_terms = $net_terms, client_created_at = UNIX_TIMESTAMP()");
|
||||
|
||||
$client_id = mysqli_insert_id($mysqli);
|
||||
|
||||
|
|
@ -499,7 +500,7 @@ if(isset($_GET['delete_invoice_item'])){
|
|||
|
||||
}
|
||||
|
||||
if(isset($_POST['add_invoice_payment'])){
|
||||
if(isset($_POST['add_payment'])){
|
||||
|
||||
$invoice_id = intval($_POST['invoice_id']);
|
||||
$date = strip_tags(mysqli_real_escape_string($mysqli,$_POST['date']));
|
||||
|
|
@ -507,12 +508,12 @@ if(isset($_POST['add_invoice_payment'])){
|
|||
$account = intval($_POST['account']);
|
||||
$payment_method = strip_tags(mysqli_real_escape_string($mysqli,$_POST['payment_method']));
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO invoice_payments SET invoice_payment_date = '$date', invoice_payment_amount = '$amount', account_id = $account, invoice_payment_method = '$payment_method', invoice_id = $invoice_id");
|
||||
mysqli_query($mysqli,"INSERT INTO payments SET payment_date = '$date', payment_amount = '$amount', account_id = $account, payment_method = '$payment_method', invoice_id = $invoice_id");
|
||||
|
||||
//Add up all the payments for the invoice and get the total amount paid to the invoice
|
||||
$sql_total_payments_amount = mysqli_query($mysqli,"SELECT SUM(invoice_payment_amount) AS total_payments_amount FROM invoice_payments WHERE invoice_id = $invoice_id");
|
||||
$sql_total_payments_amount = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS payments_amount FROM payments WHERE invoice_id = $invoice_id");
|
||||
$row = mysqli_fetch_array($sql_total_payments_amount);
|
||||
$total_payments_amount = $row['total_payments_amount'];
|
||||
$total_payments_amount = $row['payments_amount'];
|
||||
|
||||
//Get the invoice total
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM invoices WHERE invoice_id = $invoice_id");
|
||||
|
|
@ -548,29 +549,16 @@ if(isset($_POST['add_invoice_payment'])){
|
|||
}
|
||||
}
|
||||
|
||||
if(isset($_POST['edit_invoice_note'])){
|
||||
if(isset($_GET['delete_payment'])){
|
||||
$payment_id = intval($_GET['delete_payment']);
|
||||
|
||||
$invoice_id = intval($_POST['invoice_id']);
|
||||
$invoice_note = strip_tags(mysqli_real_escape_string($mysqli,$_POST['invoice_note']));
|
||||
|
||||
mysqli_query($mysqli,"UPDATE invoices SET invoice_note = '$invoice_note' WHERE invoice_id = $invoice_id");
|
||||
|
||||
$_SESSION['alert_message'] = "Notes added";
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
|
||||
}
|
||||
|
||||
if(isset($_GET['delete_invoice_payment'])){
|
||||
$invoice_payment_id = intval($_GET['delete_invoice_payment']);
|
||||
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM invoice_payments WHERE invoice_payment_id = $invoice_payment_id");
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM payments WHERE payment_id = $payment_id");
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$invoice_id = $row['invoice_id'];
|
||||
$deleted_payment_amount = $row['invoice_payment_amount'];
|
||||
$deleted_payment_amount = $row['payment_amount'];
|
||||
|
||||
//Add up all the payments for the invoice and get the total amount paid to the invoice
|
||||
$sql_total_payments_amount = mysqli_query($mysqli,"SELECT SUM(invoice_payment_amount) AS total_payments_amount FROM invoice_payments WHERE invoice_id = $invoice_id");
|
||||
$sql_total_payments_amount = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS total_payments_amount FROM payments WHERE invoice_id = $invoice_id");
|
||||
$row = mysqli_fetch_array($sql_total_payments_amount);
|
||||
$total_payments_amount = $row['total_payments_amount'];
|
||||
|
||||
|
|
@ -592,7 +580,7 @@ if(isset($_GET['delete_invoice_payment'])){
|
|||
//Update Invoice Status
|
||||
mysqli_query($mysqli,"UPDATE invoices SET invoice_status = '$invoice_status' WHERE invoice_id = $invoice_id");
|
||||
|
||||
mysqli_query($mysqli,"DELETE FROM invoice_payments WHERE invoice_payment_id = $invoice_payment_id");
|
||||
mysqli_query($mysqli,"DELETE FROM payments WHERE payment_id = $payment_id");
|
||||
|
||||
$_SESSION['alert_message'] = "Payment deleted";
|
||||
|
||||
|
|
@ -600,6 +588,19 @@ if(isset($_GET['delete_invoice_payment'])){
|
|||
|
||||
}
|
||||
|
||||
if(isset($_POST['edit_invoice_note'])){
|
||||
|
||||
$invoice_id = intval($_POST['invoice_id']);
|
||||
$invoice_note = strip_tags(mysqli_real_escape_string($mysqli,$_POST['invoice_note']));
|
||||
|
||||
mysqli_query($mysqli,"UPDATE invoices SET invoice_note = '$invoice_note' WHERE invoice_id = $invoice_id");
|
||||
|
||||
$_SESSION['alert_message'] = "Notes added";
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
|
||||
}
|
||||
|
||||
if(isset($_POST['add_client_contact'])){
|
||||
|
||||
$client_id = intval($_POST['client_id']);
|
||||
|
|
|
|||
Loading…
Reference in New Issue