mirror of https://github.com/itflow-org/itflow
Added seperate tax section and added the ability add taxes to invoice this update requires a new table called taxes see the db.sql file for the structure More to come
This commit is contained in:
parent
64b2ab3da9
commit
a2848fad09
|
|
@ -0,0 +1,28 @@
|
|||
<div class="modal" id="addTaxModal" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content bg-dark">
|
||||
<div class="modal-header text-white">
|
||||
<h5 class="modal-title"><i class="fa fa-fw fa-balance-scale mr-2"></i>New Tax</h5>
|
||||
<button type="button" class="close text-white" data-dismiss="modal">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<form action="post.php" method="post" autocomplete="off">
|
||||
<div class="modal-body bg-white">
|
||||
<div class="form-group">
|
||||
<label>Name <strong class="text-danger">*</strong></label>
|
||||
<input type="text" class="form-control" name="name" placeholder="Tax name" required autofocus>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Percent <strong class="text-danger">*</strong></label>
|
||||
<input type="number" min="0" class="form-control col-md-2" name="percent">
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer bg-white">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
|
||||
<button type="submit" name="add_tax" class="btn btn-primary">Save</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
29
db.sql
29
db.sql
|
|
@ -1,8 +1,8 @@
|
|||
-- MariaDB dump 10.17 Distrib 10.4.12-MariaDB, for debian-linux-gnu (x86_64)
|
||||
-- MariaDB dump 10.18 Distrib 10.5.8-MariaDB, for debian-linux-gnu (x86_64)
|
||||
--
|
||||
-- Host: localhost Database: admin_crm
|
||||
-- ------------------------------------------------------
|
||||
-- Server version 10.4.12-MariaDB-1:10.4.12+maria~bionic
|
||||
-- Server version 10.5.8-MariaDB-1:10.5.8+maria~focal
|
||||
|
||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
||||
|
|
@ -134,11 +134,11 @@ CREATE TABLE `clients` (
|
|||
`client_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`client_name` varchar(200) NOT NULL,
|
||||
`client_type` varchar(200) DEFAULT NULL,
|
||||
`client_country` varchar(200) DEFAULT NULL,
|
||||
`client_address` varchar(200) DEFAULT NULL,
|
||||
`client_city` varchar(200) DEFAULT NULL,
|
||||
`client_state` varchar(200) DEFAULT NULL,
|
||||
`client_zip` varchar(200) DEFAULT NULL,
|
||||
`client_country` varchar(200) DEFAULT NULL,
|
||||
`client_contact` varchar(200) DEFAULT NULL,
|
||||
`client_phone` varchar(200) DEFAULT NULL,
|
||||
`client_extension` varchar(200) DEFAULT NULL,
|
||||
|
|
@ -191,6 +191,7 @@ CREATE TABLE `contacts` (
|
|||
`contact_billing` tinyint(1) DEFAULT NULL,
|
||||
`contact_photo` varchar(200) DEFAULT NULL,
|
||||
`contact_notes` text DEFAULT NULL,
|
||||
`contact_inactive` tinyint(1) NOT NULL DEFAULT 0,
|
||||
`contact_created_at` datetime NOT NULL,
|
||||
`contact_updated_at` datetime DEFAULT NULL,
|
||||
`location_id` int(11) DEFAULT NULL,
|
||||
|
|
@ -261,6 +262,8 @@ CREATE TABLE `expenses` (
|
|||
`expense_created_at` datetime NOT NULL,
|
||||
`expense_updated_at` datetime DEFAULT NULL,
|
||||
`vendor_id` int(11) DEFAULT NULL,
|
||||
`client_id` int(11) DEFAULT NULL,
|
||||
`asset_id` int(11) DEFAULT NULL,
|
||||
`category_id` int(11) DEFAULT NULL,
|
||||
`account_id` int(11) DEFAULT NULL,
|
||||
`company_id` int(11) NOT NULL,
|
||||
|
|
@ -698,6 +701,24 @@ CREATE TABLE `software` (
|
|||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `taxes`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `taxes`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `taxes` (
|
||||
`tax_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`tax_name` varchar(200) NOT NULL,
|
||||
`tax_percent` float NOT NULL,
|
||||
`tax_created_at` datetime NOT NULL,
|
||||
`tax_updated_at` datetime DEFAULT NULL,
|
||||
`company_id` int(11) NOT NULL,
|
||||
PRIMARY KEY (`tax_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `ticket_updates`
|
||||
--
|
||||
|
|
@ -861,4 +882,4 @@ CREATE TABLE `vendors` (
|
|||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||
|
||||
-- Dump completed on 2020-03-30 20:01:15
|
||||
-- Dump completed on 2021-01-15 15:05:00
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
<div class="modal" id="editTaxModal<?php echo $tax_id; ?>" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content bg-dark">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title text-white"><i class="fa fa-fw fa-balance-scale mr-2"></i><?php echo $tax_name; ?></h5>
|
||||
<button type="button" class="close text-white" data-dismiss="modal">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<form action="post.php" method="post" autocomplete="off">
|
||||
<input type="hidden" name="tax_id" value="<?php echo $tax_id; ?>">
|
||||
<div class="modal-body bg-white">
|
||||
<div class="form-group">
|
||||
<label>Name <strong class="text-danger">*</strong></label>
|
||||
<input type="text" class="form-control" name="name" value="<?php echo $tax_name; ?>" required>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Percent <strong class="text-danger">*</strong></label>
|
||||
<input type="number" min="0" class="form-control col-md-2" name="percent" value="<?php echo $tax_percent; ?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer bg-white">
|
||||
<a href="post.php?delete_category=<?php echo $category_id; ?>" class="btn btn-danger mr-auto"><i class="fa fa-trash text-white"></i></a>
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
|
||||
<button type="submit" name="edit_tax" class="btn btn-primary">Save</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -161,7 +161,6 @@ $timezones_array = array(
|
|||
$category_types_array = array(
|
||||
'Expense',
|
||||
'Income',
|
||||
'Tax',
|
||||
'Payment Method'
|
||||
);
|
||||
|
||||
|
|
|
|||
20
invoice.php
20
invoice.php
|
|
@ -260,10 +260,24 @@ if(isset($_GET['invoice_id'])){
|
|||
<td><input type="number" step="0.01" min="0" class="form-control" style="text-align: center;" name="qty" placeholder="QTY"></td>
|
||||
<td><input type="number" step="0.01" class="form-control" style="text-align: right;" name="price" placeholder="Price"></td>
|
||||
<td>
|
||||
<select class="form-control select2" name="tax">
|
||||
<option <?php if($item_tax == '0.00'){ echo "selected"; } ?> value="0.00">None</option>
|
||||
<option <?php if($item_tax == '0.07'){ echo "selected"; } ?> value="0.07">State Tax 7%</option>
|
||||
|
||||
<select class="form-control select2" name="client" required>
|
||||
<option value="0.00">None</option>
|
||||
<?php
|
||||
|
||||
$taxes_sql = mysqli_query($mysqli,"SELECT * FROM taxes WHERE company_id = $session_company_id ORDER BY tax_name ASC");
|
||||
while($row = mysqli_fetch_array($taxes_sql)){
|
||||
$tax_id = $row['tax_id'];
|
||||
$tax_name = $row['tax_name'];
|
||||
$tax_percent = $row['tax_percent'];
|
||||
?>
|
||||
<option value="<?php echo "$tax_percent"; ?>"><?php echo "$tax_name $tax_percent%"; ?></option>
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
|
||||
</td>
|
||||
<td>
|
||||
<button class="btn btn-link text-success" type="submit" name="add_invoice_item">
|
||||
|
|
|
|||
52
post.php
52
post.php
|
|
@ -1104,6 +1104,58 @@ if(isset($_GET['delete_category'])){
|
|||
|
||||
}
|
||||
|
||||
//Tax
|
||||
|
||||
if(isset($_POST['add_tax'])){
|
||||
|
||||
$name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']));
|
||||
$percent = floatval($_POST['percent']);
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO taxes SET tax_name = '$name', tax_percent = $percent, tax_created_at = NOW(), company_id = $session_company_id");
|
||||
|
||||
//Logging
|
||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Tax', log_action = 'Created', log_description = '$name - $percent', log_created_at = NOW(), company_id = $session_company_id, user_id = $session_user_id");
|
||||
|
||||
$_SESSION['alert_message'] = "Tax added";
|
||||
|
||||
header("Location: taxes.php");
|
||||
|
||||
}
|
||||
|
||||
if(isset($_POST['edit_tax'])){
|
||||
|
||||
$tax_id = intval($_POST['tax_id']);
|
||||
$name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']));
|
||||
$percent = floatval($_POST['percent']);
|
||||
|
||||
mysqli_query($mysqli,"UPDATE taxes SET tax_name = '$name', tax_percent = $percent, tax_updated_at = NOW() WHERE tax_id = $tax_id AND company_id = $session_company_id");
|
||||
|
||||
//Logging
|
||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Tax', log_action = 'Modified', log_description = '$name - $percent', log_created_at = NOW(), company_id = $session_company_id, user_id = $session_user_id");
|
||||
|
||||
$_SESSION['alert_message'] = "Tax modified";
|
||||
|
||||
header("Location: taxes.php");
|
||||
|
||||
}
|
||||
|
||||
if(isset($_GET['delete_tax'])){
|
||||
$tax_id = intval($_GET['delete_tax']);
|
||||
|
||||
mysqli_query($mysqli,"DELETE FROM taxes WHERE tax_id = $tax_id AND company_id = $session_company_id");
|
||||
|
||||
//Logging
|
||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Tax', log_action = 'Deleted', log_description = '$tax_id', log_created_at = NOW(), company_id = $session_company_id, user_id = $session_user_id");
|
||||
|
||||
$_SESSION['alert_message'] = "Tax deleted";
|
||||
$_SESSION['alert_type'] = "danger";
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
|
||||
}
|
||||
|
||||
//End Tax
|
||||
|
||||
if(isset($_GET['alert_ack'])){
|
||||
|
||||
$alert_id = intval($_GET['alert_ack']);
|
||||
|
|
|
|||
|
|
@ -163,6 +163,12 @@
|
|||
<p>Categories</p>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="taxes.php" class="nav-link <?php if(basename($_SERVER["PHP_SELF"]) == "taxes.php") { echo "active"; } ?>">
|
||||
<i class="far fa-circle nav-icon"></i>
|
||||
<p>Taxes</p>
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a href="users.php" class="nav-link <?php if(basename($_SERVER["PHP_SELF"]) == "users.php") { echo "active"; } ?>">
|
||||
<i class="far fa-circle nav-icon"></i>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,92 @@
|
|||
<?php include("header.php");
|
||||
|
||||
//Rebuild URL
|
||||
|
||||
$url_query_strings_sb = http_build_query(array_merge($_GET,array('sb' => $sb, 'o' => $o)));
|
||||
|
||||
if(!empty($_GET['sb'])){
|
||||
$sb = mysqli_real_escape_string($mysqli,$_GET['sb']);
|
||||
}else{
|
||||
$sb = "tax_name";
|
||||
}
|
||||
|
||||
if(isset($_GET['o'])){
|
||||
if($_GET['o'] == 'ASC'){
|
||||
$o = "ASC";
|
||||
$disp = "DESC";
|
||||
}else{
|
||||
$o = "DESC";
|
||||
$disp = "ASC";
|
||||
}
|
||||
}else{
|
||||
$o = "ASC";
|
||||
$disp = "DESC";
|
||||
}
|
||||
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM taxes WHERE company_id = $session_company_id ORDER BY $sb $o");
|
||||
|
||||
$num_rows = mysqli_num_rows($sql);
|
||||
|
||||
?>
|
||||
|
||||
<div class="card mb-3">
|
||||
<div class="card-header bg-dark text-white">
|
||||
<h6 class="float-left mt-1"><i class="fa fa-fw fa-balance-scale mr-2"></i>Taxes</h6>
|
||||
<button type="button" class="btn btn-primary btn-sm float-right" data-toggle="modal" data-target="#addTaxModal"><i class="fas fa-plus"></i></button>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-borderless table-hover">
|
||||
<thead class="text-dark <?php if($num_rows == 0){ echo "d-none"; } ?>">
|
||||
<tr>
|
||||
<th><a class="text-dark" href="?<?php echo $url_query_strings_sb; ?>&sb=tax_name&o=<?php echo $disp; ?>">Name</a></th>
|
||||
<th><a class="text-dark" href="?<?php echo $url_query_strings_sb; ?>&sb=tax_percent&o=<?php echo $disp; ?>">Percent</a></th>
|
||||
<th class="text-center">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
|
||||
while($row = mysqli_fetch_array($sql)){
|
||||
$tax_id = $row['tax_id'];
|
||||
$tax_name = $row['tax_name'];
|
||||
$tax_percent = $row['tax_percent'];
|
||||
|
||||
?>
|
||||
<tr>
|
||||
<td><a class="text-dark" href="#" data-toggle="modal" data-target="#editTaxModal<?php echo $tax_id; ?>"><?php echo "$tax_name"; ?></a></td>
|
||||
<td><?php echo "$tax_percent%"; ?></td>
|
||||
<td>
|
||||
<div class="dropdown dropleft text-center">
|
||||
<button class="btn btn-secondary btn-sm" type="button" id="dropdownMenuButton" data-toggle="dropdown">
|
||||
<i class="fas fa-ellipsis-h"></i>
|
||||
</button>
|
||||
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
|
||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#editTaxModal<?php echo $tax_id; ?>">Edit</a>
|
||||
<a class="dropdown-item" href="post.php?delete_tax=<?php echo $tax_id; ?>">Delete</a>
|
||||
</div>
|
||||
</div>
|
||||
<?php include("edit_tax_modal.php"); ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
if($num_rows == 0){
|
||||
echo "<center><h3 class='text-secondary mt-3'>No Records Here</h3></center>";
|
||||
}
|
||||
?>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include("add_tax_modal.php"); ?>
|
||||
|
||||
<?php include("footer.php");
|
||||
Loading…
Reference in New Issue