GUI Touchups in Invoice, Quote, clients, vendors, client. Added 2 new fields to client mobile and contact_name, added more pictyure extension in file jpeg anb JPEG and other fixesincluding a new DB dump

This commit is contained in:
johnny@pittpc.com 2019-09-14 20:40:22 -04:00
parent 59ce30bd79
commit 62b088e79d
19 changed files with 1103 additions and 219 deletions

View File

@ -12,16 +12,16 @@
<ul class="nav nav-pills nav-justified mb-3" id="pills-tab" role="tablist">
<li class="nav-item">
<a class="nav-link active" id="pills-basic-tab" data-toggle="pill" href="#pills-basic" role="tab" aria-controls="pills-basic" aria-selected="true">Basic</a>
<a class="nav-link active" id="pills-basic-tab" data-toggle="pill" href="#pills-basic">Basic</a>
</li>
<li class="nav-item">
<a class="nav-link" id="pills-address-tab" data-toggle="pill" href="#pills-address" role="tab" aria-controls="pills-address" aria-selected="false">Address</a>
<a class="nav-link" id="pills-address-tab" data-toggle="pill" href="#pills-address">Address</a>
</li>
<li class="nav-item">
<a class="nav-link" id="pills-contact-tab" data-toggle="pill" href="#pills-contact" role="tab" aria-controls="pills-contact" aria-selected="false">Contact</a>
<a class="nav-link" id="pills-contact-tab" data-toggle="pill" href="#pills-contact">Contact</a>
</li>
<li class="nav-item">
<a class="nav-link" id="pills-more-tab" data-toggle="pill" href="#pills-more" role="tab" aria-controls="pills-more" aria-selected="false">More</a>
<a class="nav-link" id="pills-more-tab" data-toggle="pill" href="#pills-more">More</a>
</li>
</ul>
@ -29,7 +29,7 @@
<div class="tab-content" id="pills-tabContent">
<div class="tab-pane fade show active" id="pills-basic" role="tabpanel" aria-labelledby="pills-basic-tab">
<div class="tab-pane fade show active" id="pills-basic">
<div class="form-group">
<label>Name <strong class="text-danger">*</strong></label>
@ -58,7 +58,7 @@
</div>
<div class="tab-pane fade" id="pills-address" role="tabpanel" aria-labelledby="pills-address-tab">
<div class="tab-pane fade" id="pills-address">
<div class="form-group">
<label>Address</label>
@ -109,6 +109,16 @@
<div class="tab-pane fade" id="pills-contact" role="tabpanel" aria-labelledby="pills-contact-tab">
<div class="form-group">
<label>Primary Contact</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-user"></i></span>
</div>
<input type="text" class="form-control" name="contact" placeholder="Primary Contact Person">
</div>
</div>
<div class="form-group">
<label>Phone</label>
<div class="input-group">
@ -118,6 +128,16 @@
<input type="text" class="form-control" name="phone" placeholder="Phone Number" data-inputmask="'mask': '999-999-9999'">
</div>
</div>
<div class="form-group">
<label>Mobile</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-mobile-alt"></i></span>
</div>
<input type="text" class="form-control" name="mobile" placeholder="Mobile Number" data-inputmask="'mask': '999-999-9999'">
</div>
</div>
<div class="form-group">
<label>Email</label>
@ -128,7 +148,11 @@
<input type="email" class="form-control" name="email" placeholder="Email Address">
</div>
</div>
</div>
<div class="tab-pane fade" id="pills-more">
<div class="form-group">
<label>Website</label>
<div class="input-group">
@ -138,10 +162,6 @@
<input type="text" class="form-control" name="website" placeholder="Web Address">
</div>
</div>
</div>
<div class="tab-pane fade" id="pills-more" role="tabpanel" aria-labelledby="pills-more-tab">
<div class="form-group">
<label>Hours</label>

View File

@ -20,11 +20,16 @@ if(isset($_GET['client_id'])){
$client_city = $row['client_city'];
$client_state = $row['client_state'];
$client_zip = $row['client_zip'];
$client_contact = $row['client_contact'];
$client_email = $row['client_email'];
$client_phone = $row['client_phone'];
if(strlen($client_phone)>2){
$client_phone = substr($row['client_phone'],0,3)."-".substr($row['client_phone'],3,3)."-".substr($row['client_phone'],6,4);
}
$client_mobile = $row['client_mobile'];
if(strlen($client_mobile)>2){
$client_mobile = substr($row['client_mobile'],0,3)."-".substr($row['client_mobile'],3,3)."-".substr($row['client_mobile'],6,4);
}
$client_website = $row['client_website'];
$client_net_terms = $row['client_net_terms'];
if($client_net_terms == 0){
@ -108,6 +113,14 @@ if(isset($_GET['client_id'])){
<div class="col-md-3 border-left">
<h4 class="text-secondary">Contact</h4>
<?php
if(!empty($client_contact)){
?>
<i class="fa fa-fw fa-user text-secondary ml-1 mr-2 mb-2"></i> <?php echo $client_contact; ?>
<br>
<?php
}
?>
<?php
if(!empty($client_email)){
?>
<i class="fa fa-fw fa-envelope text-secondary ml-1 mr-2 mb-2"></i> <a href="mailto:<?php echo $client_email; ?>"><?php echo $client_email; ?></a>
@ -124,6 +137,14 @@ if(isset($_GET['client_id'])){
}
?>
<?php
if(!empty($client_mobile)){
?>
<i class="fa fa-fw fa-mobile-alt text-secondary ml-1 mr-2 mb-2"></i> <?php echo $client_mobile; ?>
<br>
<?php
}
?>
<?php
if(!empty($client_website)){
?>
<i class="fa fa-fw fa-globe text-secondary ml-1 mr-2 mb-2"></i> <a target="_blank" href="//<?php echo $client_website; ?>"><?php echo $client_website; ?></a>

View File

@ -1,4 +1,4 @@
<?php $sql_files_images = mysqli_query($mysqli,"SELECT * FROM files WHERE client_id = $client_id AND (file_ext LIKE 'JPG' OR file_ext LIKE 'jpg' OR file_ext LIKE 'png' OR file_ext LIKE 'PNG') ORDER BY file_id DESC"); ?>
<?php $sql_files_images = mysqli_query($mysqli,"SELECT * FROM files WHERE client_id = $client_id AND (file_ext LIKE 'JPG' OR file_ext LIKE 'jpg' OR file_ext LIKE 'JPEG' OR file_ext LIKE 'jpeg' OR file_ext LIKE 'png' OR file_ext LIKE 'PNG') ORDER BY file_id DESC"); ?>
<?php $sql_files_other = mysqli_query($mysqli,"SELECT * FROM files WHERE client_id = $client_id AND file_ext NOT LIKE 'JPG' AND file_ext NOT LIKE 'jpg' AND file_ext NOT LIKE 'png' AND file_ext NOT LIKE 'PNG' ORDER BY file_id DESC"); ?>

View File

@ -74,7 +74,6 @@ $total_pages = ceil($total_found_rows / 10);
<th><a class="text-secondary" href="?<?php echo $url_query_strings_sb; ?>&sb=vendor_name&o=<?php echo $disp; ?>">Vendor</a></th>
<th><a class="text-secondary" href="?<?php echo $url_query_strings_sb; ?>&sb=vendor_description&o=<?php echo $disp; ?>">Description</a></th>
<th>Contact</th>
<th><a class="text-secondary" href="?<?php echo $url_query_strings_sb; ?>&sb=vendor_account_number&o=<?php echo $disp; ?>">Account Number</a></th>
<th></th>
<th class="text-center">Action</th>
</tr>
@ -108,7 +107,17 @@ $total_pages = ceil($total_found_rows / 10);
?>
<tr>
<td><a class="text-dark" href="#" data-toggle="modal" data-target="#editVendorModal<?php echo $vendor_id; ?>"><?php echo $vendor_name; ?></a></td>
<td>
<a class="text-dark" href="#" data-toggle="modal" data-target="#editVendorModal<?php echo $vendor_id; ?>"><?php echo $vendor_name; ?></a>
<?php
if(!empty($vendor_account_number)){
?>
<br>
<small class="text-secondary"><?php echo $vendor_account_number; ?></small>
<?php
}
?>
</td>
<td><?php echo $vendor_description; ?></td>
<td>
<?php
@ -136,7 +145,6 @@ $total_pages = ceil($total_found_rows / 10);
}
?>
</td>
<td><?php echo $vendor_account_number; ?></td>
<td>
<?php
if($vendor_id == $vendor_id_relation){

View File

@ -39,7 +39,7 @@ if(isset($_GET['o'])){
$disp = "ASC";
}
$sql = mysqli_query($mysqli,"SELECT SQL_CALC_FOUND_ROWS * FROM clients WHERE (client_name LIKE '%$q%' OR client_email LIKE '%$q%') AND company_id = $session_company_id ORDER BY $sb $o LIMIT $record_from, $record_to");
$sql = mysqli_query($mysqli,"SELECT SQL_CALC_FOUND_ROWS * FROM clients WHERE (client_name LIKE '%$q%' OR client_email LIKE '%$q%' OR client_contact LIKE '%$q%') AND company_id = $session_company_id ORDER BY $sb $o LIMIT $record_from, $record_to");
$num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
@ -66,12 +66,11 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
<table class="table table-striped table-borderless table-hover">
<thead class="text-dark <?php if($num_rows[0] == 0){ echo "d-none"; } ?>">
<tr>
<th class="w-40"><a class="text-dark" href="?<?php echo $url_query_strings_sb; ?>&sb=client_name&o=<?php echo $disp; ?>">Name <i class="fa fa-sort-alpha<?php if($disp=='ASC'){ echo "-up"; }else{ echo "-down"; }?>"></i></a></th>
<th class="w-15"><a class="text-dark" href="?<?php echo $url_query_strings_sb; ?>&sb=client_type&o=<?php echo $disp; ?>">Type <i class="fa fa-sort"></i></a></th>
<th class="w-15"><a class="text-dark" href="?<?php echo $url_query_strings_sb; ?>&sb=client_email&o=<?php echo $disp; ?>">Email</a></th>
<th class="w-10">Phone</th>
<th class="w-10 text-right">Balance</th>
<th class="w-10 text-center">Action</th>
<th><a class="text-dark" href="?<?php echo $url_query_strings_sb; ?>&sb=client_name&o=<?php echo $disp; ?>">Name <i class="fa fa-sort-alpha<?php if($disp=='ASC'){ echo "-up"; }else{ echo "-down"; }?>"></i></a></th>
<th><a class="text-dark" href="?<?php echo $url_query_strings_sb; ?>&sb=client_type&o=<?php echo $disp; ?>">Type <i class="fa fa-sort"></i></a></th>
<th>Contact</th>
<th class="text-right">Balance</th>
<th class="text-center">Action</th>
</tr>
</thead>
<tbody>
@ -85,10 +84,15 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
$client_city = $row['client_city'];
$client_state = $row['client_state'];
$client_zip = $row['client_zip'];
$client_contact = $row['client_contact'];
$client_phone = $row['client_phone'];
if(strlen($client_phone)>2){
$client_phone = substr($row['client_phone'],0,3)."-".substr($row['client_phone'],3,3)."-".substr($row['client_phone'],6,4);
}
$client_mobile = $row['client_mobile'];
if(strlen($client_mobile)>2){
$client_mobile = substr($row['client_mobile'],0,3)."-".substr($row['client_mobile'],3,3)."-".substr($row['client_mobile'],6,4);
}
$client_email = $row['client_email'];
$client_website = $row['client_website'];
$client_net_terms = $row['client_net_terms'];
@ -117,8 +121,39 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
<tr>
<td><a href="client.php?client_id=<?php echo $client_id; ?>&tab=contacts"><?php echo $client_name; ?></a></td>
<td><?php echo $client_type; ?></td>
<td><a href="mailto:<?php echo $client_email; ?>"><?php echo $client_email; ?></a></td>
<td><?php echo $client_phone; ?></td>
<td>
<?php
if(!empty($client_contact)){
?>
<i class="fa fa-fw fa-user text-secondary mr-2 mb-2"></i><?php echo $client_contact; ?>
<br>
<?php
}
?>
<?php
if(!empty($client_phone)){
?>
<i class="fa fa-fw fa-phone text-secondary mr-2 mb-2"></i><?php echo $client_phone; ?>
<br>
<?php
}
?>
<?php
if(!empty($client_mobile)){
?>
<i class="fa fa-fw fa-mobile-alt text-secondary mr-2 mb-2"></i><?php echo $client_mobile; ?>
<br>
<?php
}
?>
<?php
if(!empty($client_email)){
?>
<i class="fa fa-fw fa-envelope text-secondary mr-2 mb-2"></i><a href="mailto:<?php echo $client_email; ?>"><?php echo $client_email; ?></a>
<?php
}
?>
</td>
<td class="text-right text-monospace <?php echo $balance_text_color; ?>">$<?php echo number_format($balance,2); ?></td>
<td>
<div class="dropdown dropleft text-center">

28
db.sql
View File

@ -1,8 +1,8 @@
-- MariaDB dump 10.17 Distrib 10.4.7-MariaDB, for debian-linux-gnu (x86_64)
-- MariaDB dump 10.17 Distrib 10.4.8-MariaDB, for debian-linux-gnu (x86_64)
--
-- Host: localhost Database: admin_crm
-- ------------------------------------------------------
-- Server version 10.4.7-MariaDB-1:10.4.7+maria~bionic
-- Server version 10.4.8-MariaDB-1:10.4.8+maria~bionic
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
@ -43,9 +43,9 @@ DROP TABLE IF EXISTS `alerts`;
CREATE TABLE `alerts` (
`alert_id` int(11) NOT NULL AUTO_INCREMENT,
`alert_type` varchar(200) NOT NULL,
`alert_message` varchar(200) NOT NULL,
`alert_message` varchar(255) NOT NULL,
`alert_date` datetime NOT NULL,
`alert_ack_date` datetime NOT NULL DEFAULT current_timestamp() ON UPDATE current_timestamp(),
`alert_ack_date` datetime DEFAULT NULL,
`company_id` int(11) NOT NULL,
PRIMARY KEY (`alert_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
@ -135,7 +135,9 @@ CREATE TABLE `clients` (
`client_city` varchar(200) DEFAULT NULL,
`client_state` varchar(200) DEFAULT NULL,
`client_zip` varchar(200) DEFAULT NULL,
`client_contact` varchar(200) DEFAULT NULL,
`client_phone` varchar(200) DEFAULT NULL,
`client_mobile` varchar(200) DEFAULT NULL,
`client_email` varchar(200) DEFAULT NULL,
`client_website` varchar(200) DEFAULT NULL,
`client_net_terms` int(10) NOT NULL,
@ -334,6 +336,7 @@ DROP TABLE IF EXISTS `invoices`;
CREATE TABLE `invoices` (
`invoice_id` int(11) NOT NULL AUTO_INCREMENT,
`invoice_number` varchar(20) NOT NULL,
`invoice_scope` varchar(255) DEFAULT NULL,
`invoice_status` varchar(200) NOT NULL,
`invoice_date` date NOT NULL,
`invoice_due` date NOT NULL,
@ -408,13 +411,14 @@ DROP TABLE IF EXISTS `logs`;
CREATE TABLE `logs` (
`log_id` int(11) NOT NULL AUTO_INCREMENT,
`log_type` varchar(200) NOT NULL,
`log_description` varchar(200) NOT NULL,
`log_action` varchar(255) NOT NULL,
`log_description` varchar(255) NOT NULL,
`log_created_at` datetime NOT NULL,
`invoice_id` int(11) DEFAULT NULL,
`quote_id` int(11) DEFAULT NULL,
`recurring_id` int(11) DEFAULT NULL,
`user_id` int(11) DEFAULT NULL,
`company_id` int(11) NOT NULL,
`company_id` int(11) DEFAULT NULL,
PRIMARY KEY (`log_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
/*!40101 SET character_set_client = @saved_cs_client */;
@ -512,6 +516,7 @@ DROP TABLE IF EXISTS `quotes`;
CREATE TABLE `quotes` (
`quote_id` int(11) NOT NULL AUTO_INCREMENT,
`quote_number` varchar(200) NOT NULL,
`quote_scope` varchar(255) DEFAULT NULL,
`quote_status` varchar(200) NOT NULL,
`quote_date` date NOT NULL,
`quote_amount` decimal(15,2) DEFAULT NULL,
@ -535,6 +540,7 @@ DROP TABLE IF EXISTS `recurring`;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `recurring` (
`recurring_id` int(11) NOT NULL AUTO_INCREMENT,
`recurring_scope` varchar(255) DEFAULT NULL,
`recurring_frequency` varchar(200) NOT NULL,
`recurring_last_sent` date DEFAULT NULL,
`recurring_next_date` date NOT NULL,
@ -591,7 +597,6 @@ CREATE TABLE `settings` (
`config_default_transfer_to_account` int(11) DEFAULT NULL,
`config_default_calendar` int(11) DEFAULT NULL,
`config_default_net_terms` int(11) DEFAULT NULL,
`config_start_page` varchar(200) DEFAULT NULL,
`config_company_name` varchar(200) DEFAULT NULL,
`config_company_address` varchar(200) DEFAULT NULL,
`config_company_city` varchar(200) DEFAULT NULL,
@ -609,10 +614,6 @@ CREATE TABLE `settings` (
`config_invoice_logo` varchar(200) DEFAULT NULL,
`config_invoice_footer` text DEFAULT NULL,
`config_quote_footer` text DEFAULT NULL,
`config_invoice_email_subject` varchar(200) DEFAULT NULL,
`config_invoice_email_body` text DEFAULT NULL,
`config_quote_email_subject` varchar(200) DEFAULT NULL,
`config_quote_email_body` varchar(200) DEFAULT NULL,
`config_invoice_next_number` int(11) DEFAULT NULL,
`config_recurring_auto_send_invoice` int(1) DEFAULT NULL,
`config_api_key` varchar(200) DEFAULT NULL,
@ -626,6 +627,9 @@ CREATE TABLE `settings` (
`config_enable_cron` int(1) DEFAULT NULL,
`enable_alert_domain_expire` int(1) DEFAULT NULL,
`enable_alert_low_balance` int(1) DEFAULT NULL,
`config_stripe_enable` int(1) DEFAULT NULL,
`config_stripe_publishable` varchar(255) DEFAULT NULL,
`config_stripe_secret` varchar(255) DEFAULT NULL,
`config_base_url` varchar(200) DEFAULT NULL,
PRIMARY KEY (`company_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
@ -814,4 +818,4 @@ CREATE TABLE `vendors` (
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2019-08-24 22:12:13
-- Dump completed on 2019-09-14 20:38:23

View File

@ -114,6 +114,16 @@
<div class="tab-pane fade" id="pills-contact<?php echo $client_id; ?>" role="tabpanel" aria-labelledby="pills-contact-tab<?php echo $client_id; ?>">
<div class="form-group">
<label>Primary Contact</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-user"></i></span>
</div>
<input type="text" class="form-control" name="contact" placeholder="Primary contact name" value="<?php echo $client_contact; ?>">
</div>
</div>
<div class="form-group">
<label>Phone</label>
<div class="input-group">
@ -123,6 +133,16 @@
<input type="text" class="form-control" name="phone" placeholder="Phone Number" value="<?php echo $client_phone; ?>" data-inputmask="'mask': '999-999-9999'">
</div>
</div>
<div class="form-group">
<label>Mobile</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-mobile-alt"></i></span>
</div>
<input type="text" class="form-control" name="mobile" placeholder="Mobile Number" value="<?php echo $client_mobile; ?>" data-inputmask="'mask': '999-999-9999'">
</div>
</div>
<div class="form-group">
<label>Email</label>
@ -133,7 +153,11 @@
<input type="email" class="form-control" name="email" placeholder="Email Address" value="<?php echo $client_email; ?>">
</div>
</div>
</div>
<div class="tab-pane fade" id="pills-more<?php echo $client_id; ?>" role="tabpanel" aria-labelledby="pills-more-tab<?php echo $client_id; ?>">
<div class="form-group">
<label>Website</label>
<div class="input-group">
@ -143,10 +167,6 @@
<input type="text" class="form-control" name="website" placeholder="Web Address" value="<?php echo $client_website; ?>">
</div>
</div>
</div>
<div class="tab-pane fade" id="pills-more<?php echo $client_id; ?>" role="tabpanel" aria-labelledby="pills-more-tab<?php echo $client_id; ?>">
<div class="form-group">
<label>Hours</label>

View File

@ -108,13 +108,10 @@ if(isset($_GET['invoice_id'], $_GET['url_key'])){
?>
<div class="row d-print-none">
<div class="col-md-6">
<h2><strong>Invoice <?php echo $invoice_number; ?></strong></h2>
</div>
<div class="col-md-6">
<div class="col-md-12">
<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_invoice=<?php echo $invoice_id; ?>&url_key=<?php echo $url_key; ?>"><i class="fa fa-fw fa-download"></i> Download PDF</a>
<a class="btn btn-primary" download target="_blank" href="guest_post.php?pdf_invoice=<?php echo $invoice_id; ?>&url_key=<?php echo $url_key; ?>"><i class="fa fa-fw fa-download"></i> Download</a>
<?php
if($invoice_status != "Paid" and $invoice_status != "Cancelled" and $invoice_status != "Draft" and $config_stripe_enable == 1){
?>
@ -124,12 +121,15 @@ if(isset($_GET['invoice_id'], $_GET['url_key'])){
</div>
</div>
<hr>
<hr class="d-print-none">
<div class="row mb-4">
<div class="col-sm-2">
<img class="img-fluid" src="<?php echo $config_invoice_logo; ?>">
</div>
</div>
<div class="col-sm-10">
<h3 class="text-right"><strong>Invoice</strong><br><small class="text-secondary"><?php echo $invoice_number; ?></small></h3>
</div>
</div>
<div class="row mb-4">
<div class="col-sm">

View File

@ -97,7 +97,7 @@ if(isset($_GET['invoice_id'])){
<input type="hidden" name="invoice_id" value="<?php echo $invoice_id; ?>">
<div class="row mb-4 d-print-none">
<div class="col-md-4">
<button class="btn btn-success btn-sm" type="submit" name="save_invoice">Save</button>
<button class="btn btn-success btn-sm" type="submit" name="save_invoice"><i class="fa fa-fw fa-check"></i> Save</button>
</div>
<div class="col-md-8">
<div class="dropdown dropleft text-center">
@ -120,54 +120,52 @@ if(isset($_GET['invoice_id'])){
</div>
</div>
</div>
</div>
</div>
<hr class="d-print-none">
<div class="row mb-4">
<div class="col-sm-2">
<img class="img-fluid" src="<?php echo $config_invoice_logo; ?>">
</div>
<div class="col-sm-10">
<h3 class="text-right"><strong>Invoice</strong><br><small class="text-secondary"><?php echo $invoice_number; ?></small></h3>
</div>
</div>
<div class="row mb-4">
<div class="col-sm">
<div class="card">
<div class="card-header">
From
</div>
<div class="card-body">
<ul class="list-unstyled">
<li><strong><?php echo $config_company_name; ?></strong></li>
<li><?php echo $config_company_address; ?></li>
<li class="mb-3"><?php echo "$config_company_city $config_company_state $config_company_zip"; ?></li>
<li><?php echo $config_company_phone; ?></li>
<li><?php echo $config_company_email; ?></li>
</ul>
</div>
</div>
<ul class="list-unstyled">
<li><h4><strong><?php echo $config_company_name; ?></strong></h4></li>
<li><?php echo $config_company_address; ?></li>
<li><?php echo "$config_company_city $config_company_state $config_company_zip"; ?></li>
<li>P: <?php echo $config_company_phone; ?></li>
<li><?php echo $config_company_email; ?></li>
</ul>
</div>
<div class="col-sm">
<div class="card">
<div class="card-header">
Bill To
</div>
<div class="card-body">
<ul class="list-unstyled">
<li><strong><?php echo $client_name; ?></strong></li>
<li><?php echo $client_address; ?></li>
<li class="mb-3"><?php echo "$client_city $client_state $client_zip"; ?></li>
<li><?php echo $client_phone; ?></li>
<li><?php echo $client_email; ?></li>
</ul>
</div>
</div>
<ul class="list-unstyled text-right">
<li><h4><strong><?php echo $client_name; ?></strong></h4></li>
<li><?php echo $client_address; ?></li>
<li><?php echo "$client_city $client_state $client_zip"; ?></li>
<li>P: <?php echo $client_phone; ?></li>
<li>E: <?php echo $client_email; ?></li>
</ul>
</div>
<div class="col-sm">
<div class="card">
<div class="card-header">
Details
</div>
<div class="card-body">
<ul class="list-unstyled">
<li class="mb-1"><strong>Invoice Number:</strong> <div class="float-right"><?php echo $invoice_number; ?></div></li>
<li class="mb-1"><strong>Invoice Date:</strong> <div class="float-right"><?php echo $invoice_date; ?></div></li>
<li><strong>Payment Due:</strong> <div class="float-right <?php echo $invoice_color; ?>"><?php echo $invoice_due; ?></div></li>
</ul>
</div>
</div>
</div>
<div class="row mb-4">
<div class="col-sm-8">
</div>
<div class="col-sm-4">
<table class="table">
<tr>
<td>Invoice Date</td>
<td class="text-right"><?php echo $invoice_date; ?></td>
</tr>
<tr>
<td>Due Date</td>
<td class="text-right"><div class="<?php echo $invoice_color; ?>"><?php echo $invoice_due; ?></div></td>
</tr>
</table>
</div>
</div>
@ -176,10 +174,6 @@ if(isset($_GET['invoice_id'])){
<div class="row mb-4">
<div class="col-md-12">
<div class="card">
<div class="card-header">
Items
</div>
<table class="table">
<thead>
<tr>
@ -210,7 +204,7 @@ if(isset($_GET['invoice_id'])){
?>
<tr>
<td class="text-center d-print-none"><a class="btn btn-sm btn-danger" href="post.php?delete_invoice_item=<?php echo $item_id; ?>"><i class="fa fa-trash"></i></a></td>
<td class="text-center d-print-none"><a class="text-danger" href="post.php?delete_invoice_item=<?php echo $item_id; ?>"><i class="fa fa-trash-alt"></i></a></td>
<td><?php echo $item_name; ?></td>
<td><?php echo $item_description; ?></td>
<td class="text-center"><?php echo $item_quantity; ?></td>
@ -228,10 +222,10 @@ if(isset($_GET['invoice_id'])){
<tr class="d-print-none">
<td></td>
<td><input type="text" class="form-control typeahead" name="name" id="item"></td>
<td><textarea class="form-control" id="description" rows="1" name="description"></textarea></td>
<td><input type="number" step="0.01" min="0" class="form-control" style="text-align: center;" name="qty"></td>
<td><input type="number" step="0.01" min="0" class="form-control" style="text-align: right;" id="price" name="price"></td>
<td><input type="text" class="form-control typeahead" name="name" id="item" placeholder="Product"></td>
<td><textarea class="form-control" id="description" rows="1" name="description" placeholder="Description"></textarea></td>
<td><input type="number" step="0.01" min="0" class="form-control" style="text-align: center;" name="qty" placeholder="Quantity"></td>
<td><input type="number" step="0.01" min="0" class="form-control" style="text-align: right;" id="price" name="price" placeholder="Price"></td>
<td>
<select dir="rtl" class="form-control" name="tax">
<option value="0.00">None</option>
@ -248,17 +242,12 @@ if(isset($_GET['invoice_id'])){
<div class="row mb-4">
<div class="col-7">
<div class="card">
<div class="card-header">
Notes
</div>
<div class="card d-none d-print-block">
<div class="card-body">
<div class="d-none d-print-block"><?php echo $invoice_note; ?></div>
<textarea rows="6" class="form-control mb-2 d-print-none" name="invoice_note"><?php echo $invoice_note; ?></textarea>
<div><?php echo $invoice_note; ?></div>
</div>
</div>
<textarea rows="6" class="form-control mb-2 d-print-none" name="invoice_note" placeholder="Notes"><?php echo $invoice_note; ?></textarea>
</div>
<div class="col-3 offset-2">
<table class="table table-borderless">
@ -296,8 +285,8 @@ if(isset($_GET['invoice_id'])){
</form>
<div class="row mb-3">
<div class="col-sm d-print-none">
<div class="row d-print-none mb-3">
<div class="col-sm">
<div class="card">
<div class="card-header">
History

439
invoice_old.php Normal file
View File

@ -0,0 +1,439 @@
<?php include("header.php"); ?>
<?php
if(isset($_GET['invoice_id'])){
$invoice_id = intval($_GET['invoice_id']);
$sql = mysqli_query($mysqli,"SELECT * FROM invoices, clients
WHERE invoices.client_id = clients.client_id
AND invoices.invoice_id = $invoice_id
AND invoices.company_id = $session_company_id"
);
if(mysqli_num_rows($sql) == 0){
echo "<center><h1 class='text-secondary mt-5'>Nothing to see here</h1></center>";
}else{
$row = mysqli_fetch_array($sql);
$invoice_id = $row['invoice_id'];
$invoice_number = $row['invoice_number'];
$invoice_status = $row['invoice_status'];
$invoice_date = $row['invoice_date'];
$invoice_due = $row['invoice_due'];
$invoice_amount = $row['invoice_amount'];
$invoice_note = $row['invoice_note'];
$invoice_url_key = $row['invoice_url_key'];
$category_id = $row['category_id'];
$client_id = $row['client_id'];
$client_name = $row['client_name'];
$client_address = $row['client_address'];
$client_city = $row['client_city'];
$client_state = $row['client_state'];
$client_zip = $row['client_zip'];
$client_email = $row['client_email'];
$client_phone = $row['client_phone'];
if(strlen($client_phone)>2){
$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'];
if($client_net_terms == 0){
$client_net_terms = $config_default_net_terms;
}
$sql_history = mysqli_query($mysqli,"SELECT * FROM history WHERE invoice_id = $invoice_id ORDER BY history_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(payment_amount) AS amount_paid FROM payments WHERE invoice_id = $invoice_id");
$row = mysqli_fetch_array($sql_amount_paid);
$amount_paid = $row['amount_paid'];
$balance = $invoice_amount - $amount_paid;
//check to see if overdue
if($invoice_status !== "Paid" AND $invoice_status !== "Draft" AND $invoice_status !== "Cancelled"){
$unixtime_invoice_due = strtotime($invoice_due) + 86400;
if($unixtime_invoice_due < time()){
$invoice_overdue = "Overdue";
}
}
//Set Badge color based off of invoice status
if($invoice_status == "Sent"){
$invoice_badge_color = "warning text-white";
}elseif($invoice_status == "Viewed"){
$invoice_badge_color = "info";
}elseif($invoice_status == "Partial"){
$invoice_badge_color = "primary";
}elseif($invoice_status == "Paid"){
$invoice_badge_color = "success";
}elseif($invoice_status == "Cancelled"){
$invoice_badge_color = "danger";
}else{
$invoice_badge_color = "secondary";
}
?>
<ol class="breadcrumb d-print-none">
<li class="breadcrumb-item">
<a href="invoices.php">Invoices</a>
</li>
<li class="breadcrumb-item">
<a href="client.php?client_id=<?php echo $client_id; ?>&tab=invoices"><?php echo $client_name; ?></a>
</li>
<li class="breadcrumb-item active"><?php echo $invoice_number; ?></li>
<span class="p-2 ml-2 badge badge-<?php echo $invoice_badge_color; ?>"><?php echo $invoice_status; ?></span>
<?php if(isset($invoice_overdue)){ ?>
<span class="p-2 ml-2 badge badge-danger"><?php echo $invoice_overdue; ?></span>
<?php } ?>
</ol>
<form action="post.php" method="post" autocomplete="off">
<input type="hidden" name="invoice_id" value="<?php echo $invoice_id; ?>">
<div class="row mb-4 d-print-none">
<div class="col-md-4">
<button class="btn btn-success btn-sm" type="submit" name="save_invoice">Save</button>
</div>
<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">
<i class="fas fa-fw fa-ellipsis-v"></i>
</button>
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#editInvoiceModal<?php echo $invoice_id; ?>">Edit</a>
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#addInvoiceCopyModal<?php echo $invoice_id; ?>">Copy</a>
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#addInvoiceRecurringModal<?php echo $invoice_id; ?>">Create Recurring</a>
<a class="dropdown-item" href="post.php?email_invoice=<?php echo $invoice_id; ?>">Send</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' and $invoice_status !== 'Cancelled'){ ?><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="guest_view_invoice.php?invoice_id=<?php echo "$invoice_id&url_key=$invoice_url_key"; ?>">Guest URL</a>
<a class="dropdown-item" href="post.php?pdf_invoice=<?php echo $invoice_id; ?>">PDF</a>
<?php if($invoice_status !== 'Cancelled' and $invoice_status !== 'Paid'){ ?>
<a class="dropdown-item" href="post.php?cancel_invoice=<?php echo $invoice_id; ?>">Cancel</a>
<?php } ?>
</div>
</div>
</div>
</div>
<div class="row mb-4">
<div class="col-sm">
<div class="card">
<div class="card-header">
From
</div>
<div class="card-body">
<ul class="list-unstyled">
<li><strong><?php echo $config_company_name; ?></strong></li>
<li><?php echo $config_company_address; ?></li>
<li class="mb-3"><?php echo "$config_company_city $config_company_state $config_company_zip"; ?></li>
<li><?php echo $config_company_phone; ?></li>
<li><?php echo $config_company_email; ?></li>
</ul>
</div>
</div>
</div>
<div class="col-sm">
<div class="card">
<div class="card-header">
Bill To
</div>
<div class="card-body">
<ul class="list-unstyled">
<li><strong><?php echo $client_name; ?></strong></li>
<li><?php echo $client_address; ?></li>
<li class="mb-3"><?php echo "$client_city $client_state $client_zip"; ?></li>
<li><?php echo $client_phone; ?></li>
<li><?php echo $client_email; ?></li>
</ul>
</div>
</div>
</div>
<div class="col-sm">
<div class="card">
<div class="card-header">
Details
</div>
<div class="card-body">
<ul class="list-unstyled">
<li class="mb-1"><strong>Invoice Number:</strong> <div class="float-right"><?php echo $invoice_number; ?></div></li>
<li class="mb-1"><strong>Invoice Date:</strong> <div class="float-right"><?php echo $invoice_date; ?></div></li>
<li><strong>Payment Due:</strong> <div class="float-right <?php echo $invoice_color; ?>"><?php echo $invoice_due; ?></div></li>
</ul>
</div>
</div>
</div>
</div>
<?php $sql_invoice_items = mysqli_query($mysqli,"SELECT * FROM invoice_items WHERE invoice_id = $invoice_id ORDER BY item_id ASC"); ?>
<div class="row mb-4">
<div class="col-md-12">
<div class="card">
<div class="card-header">
Items
</div>
<table class="table">
<thead>
<tr>
<th class="d-print-none"></th>
<th>Product</th>
<th>Description</th>
<th class="text-center">Qty</th>
<th class="text-right">Price</th>
<th class="text-right">Tax</th>
<th class="text-right">Total</th>
</tr>
</thead>
<tbody>
<?php
while($row = mysqli_fetch_array($sql_invoice_items)){
$item_id = $row['item_id'];
$item_name = $row['item_name'];
$item_description = $row['item_description'];
$item_quantity = $row['item_quantity'];
$item_price = $row['item_price'];
$item_subtotal = $row['item_price'];
$item_tax = $row['item_tax'];
$item_total = $row['item_total'];
$total_tax = $item_tax + $total_tax;
$sub_total = $item_price * $item_quantity + $sub_total;
?>
<tr>
<td class="text-center d-print-none"><a class="btn btn-sm btn-danger" href="post.php?delete_invoice_item=<?php echo $item_id; ?>"><i class="fa fa-trash"></i></a></td>
<td><?php echo $item_name; ?></td>
<td><?php echo $item_description; ?></td>
<td class="text-center"><?php echo $item_quantity; ?></td>
<td class="text-right text-monospace">$<?php echo number_format($item_price,2); ?></td>
<td class="text-right text-monospace">$<?php echo number_format($item_tax,2); ?></td>
<td class="text-right text-monospace">$<?php echo number_format($item_total,2); ?></td>
</tr>
<?php
}
?>
<tr class="d-print-none">
<td></td>
<td><input type="text" class="form-control typeahead" name="name" id="item"></td>
<td><textarea class="form-control" id="description" rows="1" name="description"></textarea></td>
<td><input type="number" step="0.01" min="0" class="form-control" style="text-align: center;" name="qty"></td>
<td><input type="number" step="0.01" min="0" class="form-control" style="text-align: right;" id="price" name="price"></td>
<td>
<select dir="rtl" class="form-control" name="tax">
<option value="0.00">None</option>
<option value="0.07">State Tax 7%</option>
</select>
</td>
<td></td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
<div class="row mb-4">
<div class="col-7">
<div class="card">
<div class="card-header">
Notes
</div>
<div class="card-body">
<div class="d-none d-print-block"><?php echo $invoice_note; ?></div>
<textarea rows="6" class="form-control mb-2 d-print-none" name="invoice_note"><?php echo $invoice_note; ?></textarea>
</div>
</div>
</div>
<div class="col-3 offset-2">
<table class="table table-borderless">
<tbody>
<tr class="border-bottom">
<td>Subtotal</td>
<td class="text-right text-monospace">$<?php echo number_format($sub_total,2); ?></td>
</tr>
<?php if($discount > 0){ ?>
<tr class="border-bottom">
<td>Discount</td>
<td class="text-right text-monospace">$<?php echo number_format($invoice_discount,2); ?></td>
</tr>
<?php } ?>
<?php if($total_tax > 0){ ?>
<tr class="border-bottom">
<td>Tax</td>
<td class="text-right text-monospace">$<?php echo number_format($total_tax,2); ?></td>
</tr>
<?php } ?>
<?php if($amount_paid > 0){ ?>
<tr class="border-bottom">
<td><div class="text-success">Paid to Date</div></td>
<td class="text-right text-monospace text-success">$<?php echo number_format($amount_paid,2); ?></td>
</tr>
<?php } ?>
<tr class="border-bottom">
<td><strong>Balance Due</strong></td>
<td class="text-right text-monospace"><strong>$<?php echo number_format($balance,2); ?></strong></td>
</tr>
</tbody>
</table>
</div>
</div>
</form>
<div class="row mb-3">
<div class="col-sm d-print-none">
<div class="card">
<div class="card-header">
History
</div>
<div class="card-body">
<table class="table">
<thead>
<tr>
<th>Date</th>
<th>Status</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<?php
while($row = mysqli_fetch_array($sql_history)){
$history_created_at = $row['history_created_at'];
$history_status = $row['history_status'];
$history_description = $row['history_description'];
?>
<tr>
<td><?php echo $history_created_at; ?></td>
<td><?php echo $history_status; ?></td>
<td><?php echo $history_description; ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
</div>
<div class="col-sm d-print-none">
<div class="card">
<div class="card-header">
Payments
</div>
<div class="card-body">
<table class="table">
<thead>
<tr>
<th>Date</th>
<th class="text-right">Amount</th>
<th>Account</th>
<th class="text-center">Action</th>
</tr>
</thead>
<tbody>
<?php
while($row = mysqli_fetch_array($sql_payments)){
$payment_id = $row['payment_id'];
$payment_date = $row['payment_date'];
$payment_amount = $row['payment_amount'];
$account_name = $row['account_name'];
?>
<tr>
<td><?php echo $payment_date; ?></td>
<td class=" text-right text-monospace">$<?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_payment=<?php echo $payment_id; ?>"><i class="fa fa-trash"></i></a></td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
</div>
</div>
<?php include("add_payment_modal.php"); ?>
<?php include("edit_invoice_modal.php"); ?>
<?php include("add_invoice_copy_modal.php"); ?>
<?php include("add_invoice_recurring_modal.php"); ?>
<?php
}
}
?>
<?php include("footer.php"); ?>
<script>
var products = [
<?php
$sql = mysqli_query($mysqli,"SELECT product_name FROM products WHERE company_id = $session_company_id");
while($row = mysqli_fetch_array($sql)){
$product_name = $row['product_name'];
echo "\"$product_name\",";
}
?>
];
var productCosts2 = [
<?php
$sql = mysqli_query($mysqli,"SELECT product_id, product_name, product_cost FROM products WHERE company_id = $session_company_id");
while($row = mysqli_fetch_array($sql)){
$product_id = $row['product_id'];
$product_name = $row['product_name'];
$product_cost = $row['product_cost'];
echo "\"$product_cost\",";
}
?>
];
var productCosts = [
<?php
$sql = mysqli_query($mysqli,"SELECT product_id, product_name, product_cost FROM products WHERE company_id = $session_company_id");
while($row = mysqli_fetch_array($sql)){
$product_id = $row['product_id'];
$product_name = $row['product_name'];
$product_cost = $row['product_cost'];
echo "{ id: '$product_id', name: '$product_name', cost: '$product_cost' },";
}
?>
];
$('#item').typeahead({
source: products,
afterSelect: function(){
$('#item').val( '<?php echo $product_name; ?>' );
}
});
</script>

View File

@ -102,29 +102,40 @@ if(isset($_POST['login'])){
<div class="container">
<div class="card card-login mx-auto mt-5 bg-dark">
<div class="card-header mt-2 text-white text-center"><h3><i class="fa fa-fw fa-network-wired mr-2"></i><?php echo $config_app_name; ?></h3></div>
<div class="card-header mt-2 text-white text-center"><h3>Login</h3></div>
<div class="card-body bg-white">
<?php if(isset($response)) { echo $response; } ?>
<form method="post">
<div class="form-group">
<div class="form-label-group">
<input type="email" id="inputEmail" name="email" class="form-control" placeholder="Email address" required autofocus>
<label for="inputEmail">Email address</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-user"></i></span>
</div>
<input type="text" class="form-control" name="email" placeholder="Username" required autofocus>
</div>
</div>
<div class="form-group">
<div class="form-label-group">
<input type="password" id="inputPassword" name="password" class="form-control" placeholder="Password" required>
<label for="inputPassword">Password</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-lock"></i></span>
</div>
<input type="password" class="form-control" name="password" placeholder="Password" required>
</div>
</div>
<div class="form-group">
<div class="form-label-group">
<input type="text" id="inputToken" name="current_code" class="form-control" placeholder="2FA Token if applicable">
<label for="inputToken">Token</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-key"></i></span>
</div>
<input type="text" class="form-control" name="current_code" placeholder="Token">
</div>
</div>
<button class="btn btn-lg btn-primary btn-block" type="submit" name="login">Sign In</button>
<button class="btn btn-primary btn-block" type="submit" name="login">Sign in</button>
</form>
</div>
</div>

162
login_new.php Normal file
View File

@ -0,0 +1,162 @@
<?php
if(!file_exists('config.php')){
header("Location: setup.php");
}
?>
<?php include("config.php"); ?>
<?php include("functions.php"); ?>
<?php
$ip = get_ip();
$os = get_os();
$browser = get_web_browser();
$device = get_device();
?>
<?php
session_start();
if(isset($_POST['login'])){
$email = mysqli_real_escape_string($mysqli,$_POST['email']);
$password = md5(mysqli_real_escape_string($mysqli,$_POST['password']));
$current_code = mysqli_real_escape_string($mysqli,$_POST['current_code']);
$sql = mysqli_query($mysqli,"SELECT * FROM users WHERE email = '$email' AND password = '$password'");
if(mysqli_num_rows($sql) == 1){
$row = mysqli_fetch_array($sql);
$token = $row['token'];
$_SESSION['user_id'] = $row['user_id'];
$_SESSION['name'] = $row['name'];
$name = $row['name'];
$user_id = $row['user_id'];
if(empty($token)){
$_SESSION['logged'] = TRUE;
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Login', log_action = 'Success', log_description = '$ip - $os - $browser - $device', log_created_at = NOW(), user_id = $user_id");
header("Location: dashboard.php");
}else{
require_once("rfc6238.php");
if(TokenAuth6238::verify($token,$current_code)){
$_SESSION['logged'] = TRUE;
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Login 2FA', log_action = 'Success', log_description = '$ip - $os - $browser - $device', log_created_at = NOW(), user_id = $user_id");
//header("Location: $config_start_page");
header("Location: dashboard.php");
}else{
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Login', log_action = '2FA Failed', log_description = '$ip - $os - $browser - $device', log_created_at = NOW(), user_id = $user_id");
$response = "
<div class='alert alert-danger'>
Invalid Code.
<button class='close' data-dismiss='alert'>&times;</button>
</div>
";
}
}
}else{
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Login', log_action = 'Failed', log_description = '$email - $ip - $os - $browser - $device', log_created_at = NOW()");
$response = "
<div class='alert alert-danger'>
Incorrect email or password.
<button class='close' data-dismiss='alert'>&times;</button>
</div>
";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title><?php echo $config_app_name; ?> | Login</title>
<!-- Custom fonts for this template-->
<link href="vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">
<!-- Custom styles for this template-->
<link href="css/sb-admin.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
</head>
<body class="bg-secondary">
<div class="container">
<div class="card card-login mx-auto mt-5 bg-dark">
<div class="card-header mt-2 text-white text-center"><h3><i class="fa fa-fw fa-network-wired mr-2"></i><?php echo $config_app_name; ?></h3></div>
<div class="card-body bg-white">
<?php if(isset($response)) { echo $response; } ?>
<form method="post">
<div class="form-group">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-user"></i></span>
</div>
<input type="text" class="form-control" name="email" placeholder="Username" required autofocus>
</div>
</div>
<div class="form-group">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-lock"></i></span>
</div>
<input type="password" class="form-control" name="password" placeholder="Password" required>
</div>
</div>
<div class="form-group">
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-key"></i></span>
</div>
<input type="text" class="form-control" name="current_code" placeholder="Token">
</div>
</div>
<button class="btn btn-primary btn-block" type="submit" name="login">Login</button>
</form>
</div>
</div>
</div>
<!-- Bootstrap core JavaScript-->
<script src="vendor/jquery/jquery.min.js"></script>
<script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- Core plugin JavaScript-->
<script src="vendor/jquery-easing/jquery.easing.min.js"></script>
<!-- Prevents resubmit on refresh or back -->
<script>
if ( window.history.replaceState ) {
window.history.replaceState( null, null, window.location.href );
}
</script>
</body>
</html>

151
login_old.php Normal file
View File

@ -0,0 +1,151 @@
<?php
if(!file_exists('config.php')){
header("Location: setup.php");
}
?>
<?php include("config.php"); ?>
<?php include("functions.php"); ?>
<?php
$ip = get_ip();
$os = get_os();
$browser = get_web_browser();
$device = get_device();
?>
<?php
session_start();
if(isset($_POST['login'])){
$email = mysqli_real_escape_string($mysqli,$_POST['email']);
$password = md5(mysqli_real_escape_string($mysqli,$_POST['password']));
$current_code = mysqli_real_escape_string($mysqli,$_POST['current_code']);
$sql = mysqli_query($mysqli,"SELECT * FROM users WHERE email = '$email' AND password = '$password'");
if(mysqli_num_rows($sql) == 1){
$row = mysqli_fetch_array($sql);
$token = $row['token'];
$_SESSION['user_id'] = $row['user_id'];
$_SESSION['name'] = $row['name'];
$name = $row['name'];
$user_id = $row['user_id'];
if(empty($token)){
$_SESSION['logged'] = TRUE;
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Login', log_action = 'Success', log_description = '$ip - $os - $browser - $device', log_created_at = NOW(), user_id = $user_id");
header("Location: dashboard.php");
}else{
require_once("rfc6238.php");
if(TokenAuth6238::verify($token,$current_code)){
$_SESSION['logged'] = TRUE;
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Login 2FA', log_action = 'Success', log_description = '$ip - $os - $browser - $device', log_created_at = NOW(), user_id = $user_id");
//header("Location: $config_start_page");
header("Location: dashboard.php");
}else{
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Login', log_action = '2FA Failed', log_description = '$ip - $os - $browser - $device', log_created_at = NOW(), user_id = $user_id");
$response = "
<div class='alert alert-danger'>
Invalid Code.
<button class='close' data-dismiss='alert'>&times;</button>
</div>
";
}
}
}else{
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Login', log_action = 'Failed', log_description = '$email - $ip - $os - $browser - $device', log_created_at = NOW()");
$response = "
<div class='alert alert-danger'>
Incorrect email or password.
<button class='close' data-dismiss='alert'>&times;</button>
</div>
";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title><?php echo $config_app_name; ?> | Login</title>
<!-- Custom fonts for this template-->
<link href="vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">
<!-- Custom styles for this template-->
<link href="css/sb-admin.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
</head>
<body class="bg-secondary">
<div class="container">
<div class="card card-login mx-auto mt-5 bg-dark">
<div class="card-header mt-2 text-white text-center"><h3><i class="fa fa-fw fa-network-wired mr-2"></i><?php echo $config_app_name; ?></h3></div>
<div class="card-body bg-white">
<?php if(isset($response)) { echo $response; } ?>
<form method="post">
<div class="form-group">
<div class="form-label-group">
<input type="email" id="inputEmail" name="email" class="form-control" placeholder="Email address" required autofocus>
<label for="inputEmail">Email address</label>
</div>
</div>
<div class="form-group">
<div class="form-label-group">
<input type="password" id="inputPassword" name="password" class="form-control" placeholder="Password" required>
<label for="inputPassword">Password</label>
</div>
</div>
<div class="form-group">
<div class="form-label-group">
<input type="text" id="inputToken" name="current_code" class="form-control" placeholder="2FA Token if applicable">
<label for="inputToken">Token</label>
</div>
</div>
<button class="btn btn-lg btn-primary btn-block" type="submit" name="login">Sign In</button>
</form>
</div>
</div>
</div>
<!-- Bootstrap core JavaScript-->
<script src="vendor/jquery/jquery.min.js"></script>
<script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- Core plugin JavaScript-->
<script src="vendor/jquery-easing/jquery.easing.min.js"></script>
<!-- Prevents resubmit on refresh or back -->
<script>
if ( window.history.replaceState ) {
window.history.replaceState( null, null, window.location.href );
}
</script>
</body>
</html>

View File

@ -448,14 +448,17 @@ if(isset($_POST['add_client'])){
$city = strip_tags(mysqli_real_escape_string($mysqli,$_POST['city']));
$state = strip_tags(mysqli_real_escape_string($mysqli,$_POST['state']));
$zip = strip_tags(mysqli_real_escape_string($mysqli,$_POST['zip']));
$contact = strip_tags(mysqli_real_escape_string($mysqli,$_POST['contact']));
$phone = strip_tags(mysqli_real_escape_string($mysqli,$_POST['phone']));
$phone = preg_replace("/[^0-9]/", '',$phone);
$mobile = strip_tags(mysqli_real_escape_string($mysqli,$_POST['mobile']));
$mobile = preg_replace("/[^0-9]/", '',$mobile);
$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']);
$hours = strip_tags(mysqli_real_escape_string($mysqli,$_POST['hours']));
mysqli_query($mysqli,"INSERT INTO clients SET client_name = '$name', client_type = '$type', 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_hours = '$hours', client_created_at = NOW(), company_id = $session_company_id");
mysqli_query($mysqli,"INSERT INTO clients SET client_name = '$name', client_type = '$type', client_address = '$address', client_city = '$city', client_state = '$state', client_zip = '$zip', client_contact = '$contact', client_phone = '$phone', client_mobile = '$mobile', client_email = '$email', client_website = '$website', client_net_terms = $net_terms, client_hours = '$hours', client_created_at = NOW(), company_id = $session_company_id");
$client_id = mysqli_insert_id($mysqli);
@ -480,14 +483,17 @@ if(isset($_POST['edit_client'])){
$city = strip_tags(mysqli_real_escape_string($mysqli,$_POST['city']));
$state = strip_tags(mysqli_real_escape_string($mysqli,$_POST['state']));
$zip = strip_tags(mysqli_real_escape_string($mysqli,$_POST['zip']));
$contact = strip_tags(mysqli_real_escape_string($mysqli,$_POST['contact']));
$phone = strip_tags(mysqli_real_escape_string($mysqli,$_POST['phone']));
$phone = preg_replace("/[^0-9]/", '',$phone);
$mobile = strip_tags(mysqli_real_escape_string($mysqli,$_POST['mobile']));
$mobile = preg_replace("/[^0-9]/", '',$mobile);
$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']);
$hours = strip_tags(mysqli_real_escape_string($mysqli,$_POST['hours']));
mysqli_query($mysqli,"UPDATE clients SET client_name = '$name', client_type = '$type', 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_hours = '$hours', client_updated_at = NOW() WHERE client_id = $client_id AND company_id = $session_company_id");
mysqli_query($mysqli,"UPDATE clients SET client_name = '$name', client_type = '$type', client_address = '$address', client_city = '$city', client_state = '$state', client_zip = '$zip', client_contact = '$contact', client_phone = '$phone', client_mobile = '$mobile', client_email = '$email', client_website = '$website', client_net_terms = $net_terms, client_hours = '$hours', client_updated_at = NOW() WHERE client_id = $client_id AND company_id = $session_company_id");
//Logging
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Client', log_action = 'Modified', log_description = '$name', log_created_at = NOW(), company_id = $session_company_id, user_id = $session_user_id");

109
quote.php
View File

@ -65,11 +65,11 @@ if(isset($_GET['quote_id'])){
<span class="ml-3 p-2 badge badge-<?php echo $quote_badge_color; ?>"><?php echo $quote_status; ?></span>
</ol>
<form class="d-print-none" action="post.php" method="post">
<form action="post.php" method="post" autocomplete="off">
<input type="hidden" name="quote_id" value="<?php echo $quote_id; ?>">
<div class="row mb-4 d-print-none">
<div class="col-md-4">
<button class="btn btn-success btn-sm" type="submit" name="save_quote">Save</button>
<button class="btn btn-success btn-sm" type="submit" name="save_quote"><i class="fa fa-fw fa-check"></i> Save</button>
</div>
<div class="col-md-8">
<div class="dropdown dropleft text-center">
@ -91,64 +91,56 @@ if(isset($_GET['quote_id'])){
</div>
</div>
</div>
</div>
</div>
<hr class="d-print-none">
<div class="row mb-4">
<div class="col-sm">
<div class="card">
<div class="card-header">
From
</div>
<div class="card-body">
<ul class="list-unstyled">
<li><strong><?php echo $config_company_name; ?></strong></li>
<li><?php echo $config_company_address; ?></li>
<li class="mb-3"><?php echo "$config_company_city $config_company_state $config_company_zip"; ?></li>
<li><?php echo $config_company_phone; ?></li>
<li><?php echo $config_company_email; ?></li>
</ul>
</div>
</div>
<div class="col-sm-2">
<img class="img-fluid" src="<?php echo $config_invoice_logo; ?>">
</div>
<div class="col-sm">
<div class="card">
<div class="card-header">
Quote To
</div>
<div class="card-body">
<ul class="list-unstyled">
<li><strong><?php echo $client_name; ?></strong></li>
<li><?php echo $client_address; ?></li>
<li class="mb-3"><?php echo "$client_city $client_state $client_zip"; ?></li>
<li><?php echo $client_phone; ?></li>
<li><?php echo $client_email; ?></li>
</ul>
</div>
</div>
</div>
<div class="col-sm">
<div class="card">
<div class="card-header">
Details
</div>
<div class="card-body">
<ul class="list-unstyled">
<li class="mb-1"><strong>Quote Number:</strong> <div class="float-right"><?php echo $quote_number; ?></div></li>
<li class="mb-1"><strong>Quote Date:</strong> <div class="float-right"><?php echo $quote_date; ?></div></li>
</ul>
</div>
</div>
<div class="col-sm-10">
<h3 class="text-right"><strong>Quote</strong><br><small class="text-secondary"><?php echo $quote_number; ?></small></h3>
</div>
</div>
<div class="row mb-4">
<div class="col-sm">
<ul class="list-unstyled">
<li><h4><strong><?php echo $config_company_name; ?></strong></h4></li>
<li><?php echo $config_company_address; ?></li>
<li><?php echo "$config_company_city $config_company_state $config_company_zip"; ?></li>
<li>P: <?php echo $config_company_phone; ?></li>
<li><?php echo $config_company_email; ?></li>
</ul>
</div>
<div class="col-sm">
<ul class="list-unstyled text-right">
<li><h4><strong><?php echo $client_name; ?></strong></h4></li>
<li><?php echo $client_address; ?></li>
<li><?php echo "$client_city $client_state $client_zip"; ?></li>
<li>P: <?php echo $client_phone; ?></li>
<li>E: <?php echo $client_email; ?></li>
</ul>
</div>
</div>
<div class="row mb-4">
<div class="col-sm-8">
</div>
<div class="col-sm-4">
<table class="table">
<tr>
<td>Quote Date</td>
<td class="text-right"><?php echo $quote_date; ?></td>
</tr>
</table>
</div>
</div>
<?php $sql_items = mysqli_query($mysqli,"SELECT * FROM invoice_items WHERE quote_id = $quote_id ORDER BY item_id ASC"); ?>
<div class="row mb-4">
<div class="col-md-12">
<div class="card">
<div class="card-header">
Items
</div>
<table class="table">
<thead>
@ -180,7 +172,7 @@ if(isset($_GET['quote_id'])){
?>
<tr>
<td class="text-center d-print-none"><a class="btn btn-danger btn-sm" href="post.php?delete_quote_item=<?php echo $item_id; ?>"><i class="fa fa-trash"></i></a></td>
<td class="text-center d-print-none"><a class="text-danger" href="post.php?delete_quote_item=<?php echo $item_id; ?>"><i class="fa fa-trash-alt"></i></a></td>
<td><?php echo $item_name; ?></td>
<td><?php echo $item_description; ?></td>
<td class="text-center"><?php echo $item_quantity; ?></td>
@ -198,10 +190,10 @@ if(isset($_GET['quote_id'])){
<tr class="d-print-none">
<input type="hidden" name="quote_id" value="<?php echo $quote_id; ?>">
<td></td>
<td><input type="text" class="form-control" name="name"></td>
<td><textarea class="form-control" rows="1" name="description"></textarea></td>
<td><input type="number" step="0.01" min="0" class="form-control" style="text-align: center;" name="qty"></td>
<td><input type="number" step="0.01" min="0" class="form-control" style="text-align: right;" name="price"></td>
<td><input type="text" class="form-control" name="name" placeholder="Product"></td>
<td><textarea class="form-control" rows="1" name="description" placeholder="Description"></textarea></td>
<td><input type="number" step="0.01" min="0" class="form-control" style="text-align: center;" name="qty" placeholder="Quantity"></td>
<td><input type="number" step="0.01" min="0" class="form-control" style="text-align: right;" name="price" placeholder="Price"></td>
<td>
<select dir="rtl" class="form-control" name="tax">
<option value="0.00">None</option>
@ -218,15 +210,12 @@ if(isset($_GET['quote_id'])){
<div class="row mb-4">
<div class="col-7">
<div class="card">
<div class="card-header">
Notes
</div>
<div class="card d-none d-print-block">
<div class="card-body">
<div class="d-none d-print-block"><?php echo $quote_note; ?></div>
<textarea rows="6" class="form-control mb-2 d-print-none" name="quote_note"><?php echo $quote_note; ?></textarea>
<div><?php echo $quote_note; ?></div>
</div>
</div>
<textarea rows="6" class="form-control mb-2 d-print-none" name="quote_note" placeholder="Notes"><?php echo $quote_note; ?></textarea>
</div>
<div class="col-3 offset-2">

View File

@ -107,7 +107,7 @@
?>
<tr>
<td><?php echo ucwords($recurring_frequency); ?>ly</td>
<td><a href="recurring_invoice.php?recurring_id=<?php echo $recurring_id; ?>"><?php echo ucwords($recurring_frequency); ?>ly</a></td>
<td><a href="client.php?client_id=<?php echo $client_id; ?>&tab=recurring"><?php echo $client_name; ?></a></td>
<td><?php echo $recurring_last_sent; ?></td>
<td><?php echo $recurring_next_date; ?></td>

View File

@ -3,11 +3,11 @@
<?php
$sql_recent_logins = mysqli_query($mysqli,"SELECT * FROM logs
WHERE log_type = 'Login' AND log_action = 'Success' AND user_id = $session_user_id
ORDER BY log_id DESC LIMIT 8");
ORDER BY log_id DESC LIMIT 3");
$sql_recent_logs = mysqli_query($mysqli,"SELECT * FROM logs
WHERE user_id = $session_user_id
ORDER BY log_id DESC LIMIT 8");
ORDER BY log_id DESC LIMIT 5");
?>
@ -73,34 +73,6 @@ $sql_recent_logs = mysqli_query($mysqli,"SELECT * FROM logs
</form>
</div>
<div class="col-md-4">
<h5 class="text-secondary mb-4">Recent Logs</h5>
<table class="table">
<tbody>
<?php
while($row = mysqli_fetch_array($sql_recent_logs)){
$log_id = $row['log_id'];
$log_type = $row['log_type'];
$log_action = $row['log_action'];
$log_description = $row['log_description'];
$log_created_at = $row['log_created_at'];
?>
<tr>
<td><i class="fa fa-fw fa-pencil-alt text-secondary"></i> <?php echo $log_type; ?></td>
<td><?php echo $log_action; ?></td>
<td><i class="fa fa-fw fa-clock text-secondary"></i> <?php echo $log_created_at; ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
<div class="col-md-5">
<h5 class="text-secondary mb-4">Recent Logins</h5>
@ -125,6 +97,44 @@ $sql_recent_logs = mysqli_query($mysqli,"SELECT * FROM logs
</tbody>
</table>
</div>
<div class="col-md-4">
<h5 class="text-secondary mb-4">Recent Logs</h5>
<table class="table">
<tbody>
<?php
while($row = mysqli_fetch_array($sql_recent_logs)){
$log_id = $row['log_id'];
$log_type = $row['log_type'];
$log_action = $row['log_action'];
$log_description = $row['log_description'];
$log_created_at = $row['log_created_at'];
if($log_action == 'Created'){
$log_icon = "plus";
}elseif($log_action == 'Modified'){
$log_icon = "edit";
}elseif($log_action == 'Deleted'){
$log_icon = "trash-alt";
}else{
$log_icon = "pencil";
}
?>
<tr>
<td><i class="fa fa-fw text-secondary fa-<?php echo $log_icon; ?>"></i> <?php echo $log_type; ?></td>
<td><i class="fa fa-fw fa-clock text-secondary"></i> <?php echo $log_created_at; ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
</div>
</div>
<form class="p-3" action="post.php" method="post" autocomplete="off">

View File

@ -72,6 +72,7 @@
<th><a class="text-dark" href="?<?php echo $url_query_strings_sb; ?>&sb=email&o=<?php echo $disp; ?>">Email</a></th>
<th>Type</th>
<th>Status</th>
<th>Last Login</th>
<th class="text-center">Action</th>
</tr>
</thead>
@ -86,7 +87,15 @@
$avatar = $row['avatar'];
$client_id = $row['client_id'];
$initials = initials($name);
$sql_last_login = mysqli_query($mysqli,"SELECT * FROM logs
WHERE user_id = $user_id AND log_type = 'Login'
ORDER BY log_id DESC LIMIT 1"
);
$row = mysqli_fetch_array($sql_last_login);
$log_created_at = $row['log_created_at'];
$log_description = $row['log_description'];
?>
<tr>
<td class="text-center">
@ -107,6 +116,7 @@
<td><a href="mailto:<?php echo $email; ?>"><?php echo $email; ?></a></td>
<td>Client</td>
<td>Status</td>
<td><?php echo $log_created_at; ?> <br> <small class="text-secondary"><?php echo $log_description; ?></small></td>
<td>
<div class="dropdown dropleft text-center">
<button class="btn btn-secondary btn-sm" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">

View File

@ -39,9 +39,9 @@
$num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
$total_found_rows = $num_rows[0];
$total_pages = ceil($total_found_rows / 10);
?>
<div class="card mb-3">
<div class="card-header bg-dark text-white">
<h6 class="float-left mt-2"><i class="fa fa-fw fa-building mr-2"></i>Vendors</h6>
@ -64,7 +64,6 @@
<th><a class="text-dark" href="?<?php echo $url_query_strings_sb; ?>&sb=vendor_name&o=<?php echo $disp; ?>">Vendor</a></th>
<th><a class="text-dark" href="?<?php echo $url_query_strings_sb; ?>&sb=vendor_description&o=<?php echo $disp; ?>">Description</a></th>
<th>Contact</th>
<th><a class="text-dark" href="?<?php echo $url_query_strings_sb; ?>&sb=vendor_account_number&o=<?php echo $disp; ?>">Account Number</a></th>
<th class="text-center">Action</th>
</tr>
</thead>
@ -89,7 +88,18 @@
$vendor_website = $row['vendor_website'];
?>
<tr>
<td><a class="text-dark" href="#" data-toggle="modal" data-target="#editVendorModal<?php echo $vendor_id; ?>"><?php echo $vendor_name; ?></a></td>
<td>
<a class="text-dark" href="#" data-toggle="modal" data-target="#editVendorModal<?php echo $vendor_id; ?>"><?php echo $vendor_name; ?><a>
<?php
if(!empty($vendor_account_number)){
?>
<br>
<small class="text-secondary"><?php echo $vendor_account_number; ?></small>
<?php
}
?>
</td>
<td><?php echo $vendor_description; ?></td>
<td>
<?php
@ -117,7 +127,6 @@
}
?>
</td>
<td><?php echo $vendor_account_number; ?></td>
<td>
<div class="dropdown dropleft text-center">
<button class="btn btn-secondary btn-sm" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">