mirror of https://github.com/itflow-org/itflow
Remove some old files, updated guest urls to work with the new multi company features, and some other multi company update
This commit is contained in:
parent
01f820b394
commit
5ca8d201b0
|
|
@ -0,0 +1,31 @@
|
|||
<div class="modal" id="addCompanyModal" 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-user-plus mr-2"></i>New Company</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>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-building"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="name" placeholder="Company Name" required autofocus>
|
||||
</div>
|
||||
</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_company" class="btn btn-primary">Save</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
239
api.php
239
api.php
|
|
@ -1,149 +1,160 @@
|
|||
<?php include("config.php"); ?>
|
||||
|
||||
<?php
|
||||
//Check Key
|
||||
if(isset($_GET['api_key'])){
|
||||
$config_api_key = $_GET['api_key'];
|
||||
|
||||
include("config.php");
|
||||
|
||||
if($_GET['api_key'] == $config_api_key){
|
||||
|
||||
if(isset($_GET['cid'])){
|
||||
|
||||
$cid = intval($_GET['cid']);
|
||||
|
||||
$sql = mysqli_query($mysqli,"SELECT client_name AS name FROM clients WHERE client_phone = $cid UNION SELECT contact_name AS name FROM contacts WHERE contact_phone = $cid UNION SELECT location_name AS name FROM locations WHERE location_phone = $cid UNION SELECT vendor_name AS name FROM vendors WHERE vendor_phone = $cid");
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM settings, companies WHERE settings.company_id = companies.company_id AND settings.config_api_key = '$config_api_key'");
|
||||
|
||||
if(mysqli_num_rows($sql) == 1){
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$name = $row['name'];
|
||||
$company_id = $row['company_id'];
|
||||
|
||||
echo $name;
|
||||
if(isset($_GET['cid'])){
|
||||
|
||||
}
|
||||
$cid = intval($_GET['cid']);
|
||||
|
||||
if(isset($_GET['incoming_call'])){
|
||||
$sql = mysqli_query($mysqli,"SELECT client_name AS name FROM clients WHERE client_phone = $cid AND company_id = $company_id UNION SELECT contact_name AS name FROM contacts WHERE contact_phone = $cid AND company_id = $company_id UNION SELECT contact_name AS name FROM contacts WHERE contact_mobile = $cid AND company_id = $company_id UNION SELECT location_name AS name FROM locations WHERE location_phone = $cid AND company_id = $company_id UNION SELECT vendor_name AS name FROM vendors WHERE vendor_phone = $cid AND company_id = $company_id");
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'call', log_description = 'incoming', log_created_at = NOW()");
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$name = $row['name'];
|
||||
|
||||
}
|
||||
echo $name;
|
||||
|
||||
if(isset($_GET['client_numbers'])){
|
||||
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM clients;");
|
||||
|
||||
while($row = mysqli_fetch_array($sql)){
|
||||
$client_name = $row['client_name'];
|
||||
$client_phone = $row['client_phone'];
|
||||
|
||||
echo "$client_name - $client_phone<br>";
|
||||
}
|
||||
|
||||
}
|
||||
if(isset($_GET['incoming_call'])){
|
||||
|
||||
if(isset($_GET['phonebook'])){
|
||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'call', log_description = 'incoming', log_created_at = NOW(), company_id = $company_id");
|
||||
|
||||
header('Content-type: text/xml');
|
||||
header('Pragma: public');
|
||||
header('Cache-control: private');
|
||||
header('Expires: -1');
|
||||
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
|
||||
echo '<AddressBook>';
|
||||
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM clients;");
|
||||
|
||||
while($row = mysqli_fetch_array($sql)){
|
||||
$client_name = $row['client_name'];
|
||||
$client_phone = $row['client_phone'];
|
||||
|
||||
?>
|
||||
<Contact>
|
||||
<LastName><?php echo $client_name; ?></LastName>
|
||||
<Phone>
|
||||
<phonenumber><?php echo $client_phone; ?></phonenumber>
|
||||
</Phone>
|
||||
<Groups>
|
||||
<groupid>0</groupid>
|
||||
</Groups>
|
||||
</Contact>
|
||||
<?php
|
||||
}
|
||||
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM contacts;");
|
||||
if(isset($_GET['client_numbers'])){
|
||||
|
||||
while($row = mysqli_fetch_array($sql)){
|
||||
$vendor_name = $row['contact_name'];
|
||||
$vendor_phone = $row['contact_phone'];
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM clients WHERE company_id = $company_id");
|
||||
|
||||
while($row = mysqli_fetch_array($sql)){
|
||||
$client_name = $row['client_name'];
|
||||
$client_phone = $row['client_phone'];
|
||||
|
||||
echo "$client_name - $client_phone<br>";
|
||||
}
|
||||
|
||||
?>
|
||||
<Contact>
|
||||
<LastName><?php echo $contact_name; ?></LastName>
|
||||
<Phone>
|
||||
<phonenumber><?php echo $contact_phone; ?></phonenumber>
|
||||
</Phone>
|
||||
<Groups>
|
||||
<groupid>1</groupid>
|
||||
</Groups>
|
||||
</Contact>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM vendors;");
|
||||
if(isset($_GET['phonebook'])){
|
||||
|
||||
while($row = mysqli_fetch_array($sql)){
|
||||
$vendor_name = $row['vendor_name'];
|
||||
$vendor_phone = $row['vendor_phone'];
|
||||
header('Content-type: text/xml');
|
||||
header('Pragma: public');
|
||||
header('Cache-control: private');
|
||||
header('Expires: -1');
|
||||
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>";
|
||||
echo '<AddressBook>';
|
||||
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM clients WHERE company_id = $company_id");
|
||||
|
||||
while($row = mysqli_fetch_array($sql)){
|
||||
$client_name = $row['client_name'];
|
||||
$client_phone = $row['client_phone'];
|
||||
|
||||
?>
|
||||
<Contact>
|
||||
<LastName><?php echo $client_name; ?></LastName>
|
||||
<Phone>
|
||||
<phonenumber><?php echo $client_phone; ?></phonenumber>
|
||||
</Phone>
|
||||
<Groups>
|
||||
<groupid>0</groupid>
|
||||
</Groups>
|
||||
</Contact>
|
||||
<?php
|
||||
}
|
||||
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM contacts WHERE company_id = $company_id");
|
||||
|
||||
while($row = mysqli_fetch_array($sql)){
|
||||
$vendor_name = $row['contact_name'];
|
||||
$vendor_phone = $row['contact_phone'];
|
||||
|
||||
?>
|
||||
<Contact>
|
||||
<LastName><?php echo $contact_name; ?></LastName>
|
||||
<Phone>
|
||||
<phonenumber><?php echo $contact_phone; ?></phonenumber>
|
||||
</Phone>
|
||||
<Groups>
|
||||
<groupid>1</groupid>
|
||||
</Groups>
|
||||
</Contact>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM vendors WHERE company_id = $company_id");
|
||||
|
||||
while($row = mysqli_fetch_array($sql)){
|
||||
$vendor_name = $row['vendor_name'];
|
||||
$vendor_phone = $row['vendor_phone'];
|
||||
|
||||
?>
|
||||
<Contact>
|
||||
<LastName><?php echo $vendor_name; ?></LastName>
|
||||
<Phone>
|
||||
<phonenumber><?php echo $vendor_phone; ?></phonenumber>
|
||||
</Phone>
|
||||
<Groups>
|
||||
<groupid>2</groupid>
|
||||
</Groups>
|
||||
</Contact>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
echo '</AddressBook>';
|
||||
|
||||
?>
|
||||
<Contact>
|
||||
<LastName><?php echo $vendor_name; ?></LastName>
|
||||
<Phone>
|
||||
<phonenumber><?php echo $vendor_phone; ?></phonenumber>
|
||||
</Phone>
|
||||
<Groups>
|
||||
<groupid>2</groupid>
|
||||
</Groups>
|
||||
</Contact>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
echo '</AddressBook>';
|
||||
if(isset($_GET['client_emails'])){
|
||||
|
||||
}
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM clients WHERE company_id = $company_id");
|
||||
|
||||
if(isset($_GET['client_emails'])){
|
||||
while($row = mysqli_fetch_array($sql)){
|
||||
$client_name = $row['client_name'];
|
||||
$client_email = $row['client_email'];
|
||||
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM clients;");
|
||||
echo "$client_name - $client_email<br>";
|
||||
}
|
||||
|
||||
while($row = mysqli_fetch_array($sql)){
|
||||
$client_name = $row['client_name'];
|
||||
$client_email = $row['client_email'];
|
||||
|
||||
echo "$client_name - $client_email<br>";
|
||||
}
|
||||
|
||||
if(isset($_GET['account_balance'])){
|
||||
|
||||
$client_id = intval($_GET['account_balance']);
|
||||
|
||||
//Add up all the payments for the invoice and get the total amount paid to the invoice
|
||||
$sql_invoice_amounts = mysqli_query($mysqli,"SELECT SUM(invoice_amount) AS invoice_amounts FROM invoices WHERE client_id = $client_id AND invoice_status NOT LIKE 'Draft' AND invoice_status NOT LIKE 'Cancelled' AND company_id = $company_id");
|
||||
$row = mysqli_fetch_array($sql_invoice_amounts);
|
||||
|
||||
$invoice_amounts = $row['invoice_amounts'];
|
||||
|
||||
$sql_amount_paid = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS amount_paid FROM payments, invoices WHERE payments.invoice_id = invoices.invoice_id AND invoices.client_id = $client_id AND payments.company_id = $company_id");
|
||||
$row = mysqli_fetch_array($sql_amount_paid);
|
||||
|
||||
$amount_paid = $row['amount_paid'];
|
||||
|
||||
$balance = $invoice_amounts - $amount_paid;
|
||||
|
||||
echo $balance;
|
||||
|
||||
}
|
||||
|
||||
}else{
|
||||
echo "Incorrect API Key";
|
||||
}
|
||||
|
||||
if(isset($_GET['account_balance'])){
|
||||
|
||||
$client_id = intval($_GET['account_balance']);
|
||||
|
||||
//Add up all the payments for the invoice and get the total amount paid to the invoice
|
||||
$sql_invoice_amounts = mysqli_query($mysqli,"SELECT SUM(invoice_amount) AS invoice_amounts FROM invoices WHERE client_id = $client_id AND invoice_status NOT LIKE 'Draft' AND invoice_status NOT LIKE 'Cancelled'");
|
||||
$row = mysqli_fetch_array($sql_invoice_amounts);
|
||||
|
||||
$invoice_amounts = $row['invoice_amounts'];
|
||||
|
||||
$sql_amount_paid = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS amount_paid FROM payments, invoices WHERE payments.invoice_id = invoices.invoice_id AND invoices.client_id = $client_id");
|
||||
$row = mysqli_fetch_array($sql_amount_paid);
|
||||
|
||||
$amount_paid = $row['amount_paid'];
|
||||
|
||||
$balance = $invoice_amounts - $amount_paid;
|
||||
|
||||
echo $balance;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}else{
|
||||
header("Location: login.php");
|
||||
echo "Missing the API Key";
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -15,7 +15,7 @@ if(isset($_GET['calendar_id'])){
|
|||
|
||||
<?php
|
||||
//loop through IDs and create a modal for each
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM events, calendars WHERE events.calendar_id = calendars.calendar_id AND company_id = $session_company_id");
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM events, calendars WHERE events.calendar_id = calendars.calendar_id AND calendars.company_id = $session_company_id");
|
||||
while($row = mysqli_fetch_array($sql)){
|
||||
$event_id = $row['event_id'];
|
||||
$event_title = $row['event_title'];
|
||||
|
|
@ -63,7 +63,7 @@ while($row = mysqli_fetch_array($sql)){
|
|||
},
|
||||
events: [
|
||||
<?php
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM events, calendars WHERE events.calendar_id = calendars.calendar_id AND company_id = $session_company_id");
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM events, calendars WHERE events.calendar_id = calendars.calendar_id AND calendars.company_id = $session_company_id");
|
||||
while($row = mysqli_fetch_array($sql)){
|
||||
$event_id = $row['event_id'];
|
||||
$event_title = $row['event_title'];
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
if(isset($_GET['client_id'])){
|
||||
$client_id = intval($_GET['client_id']);
|
||||
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM clients WHERE client_id = $client_id AND company_id = $session_company_id");
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM clients WHERE client_id = $client_id");
|
||||
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$client_name = $row['client_name'];
|
||||
|
|
|
|||
|
|
@ -88,7 +88,7 @@ $total_pages = ceil($total_found_rows / 10);
|
|||
$contact_phone = substr($row['contact_phone'],0,3)."-".substr($row['contact_phone'],3,3)."-".substr($row['contact_phone'],6,4);
|
||||
}
|
||||
$contact_mobile = $row['contact_mobile'];
|
||||
if(strlen($contact_phone)>2){
|
||||
if(strlen($contact_mobile)>2){
|
||||
$contact_mobile = substr($row['contact_mobile'],0,3)."-".substr($row['contact_mobile'],3,3)."-".substr($row['contact_mobile'],6,4);
|
||||
}
|
||||
$contact_email = $row['contact_email'];
|
||||
|
|
|
|||
100
clients_old.php
100
clients_old.php
|
|
@ -1,100 +0,0 @@
|
|||
<?php include("header.php"); ?>
|
||||
|
||||
<?php $sql = mysqli_query($mysqli,"SELECT * FROM clients ORDER BY client_name ASC"); ?>
|
||||
|
||||
|
||||
<div class="card mb-3">
|
||||
<div class="card-header">
|
||||
<h6 class="float-left mt-2"><i class="fa fa-users mr-2"></i>Clients</h6>
|
||||
<button type="button" class="btn btn-primary btn-sm float-right" data-toggle="modal" data-target="#addClientModal"><i class="fas fa-fw fa-user-plus"></i></button>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-borderless table-hover" id="dataTable" width="100%" cellspacing="0">
|
||||
<thead class="thead-dark">
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Type</th>
|
||||
<th>Email</th>
|
||||
<th>Phone</th>
|
||||
<th class="text-right">Balance</th>
|
||||
<th class="text-center">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
|
||||
while($row = mysqli_fetch_array($sql)){
|
||||
$client_id = $row['client_id'];
|
||||
$client_name = $row['client_name'];
|
||||
$client_type = $row['client_type'];
|
||||
$client_address = $row['client_address'];
|
||||
$client_city = $row['client_city'];
|
||||
$client_state = $row['client_state'];
|
||||
$client_zip = $row['client_zip'];
|
||||
$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_email = $row['client_email'];
|
||||
$client_website = $row['client_website'];
|
||||
$client_net_terms = $row['client_net_terms'];
|
||||
if($client_net_terms == 0){
|
||||
$client_net_terms = $config_default_net_terms;
|
||||
}
|
||||
|
||||
//Add up all the payments for the invoice and get the total amount paid to the invoice
|
||||
$sql_invoice_amounts = mysqli_query($mysqli,"SELECT SUM(invoice_amount) AS invoice_amounts FROM invoices WHERE client_id = $client_id AND invoice_status NOT LIKE 'Draft' AND invoice_status NOT LIKE 'Cancelled' ");
|
||||
$row = mysqli_fetch_array($sql_invoice_amounts);
|
||||
|
||||
$invoice_amounts = $row['invoice_amounts'];
|
||||
|
||||
$sql_amount_paid = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS amount_paid FROM payments, invoices WHERE payments.invoice_id = invoices.invoice_id AND invoices.client_id = $client_id");
|
||||
$row = mysqli_fetch_array($sql_amount_paid);
|
||||
|
||||
$amount_paid = $row['amount_paid'];
|
||||
|
||||
$balance = $invoice_amounts - $amount_paid;
|
||||
//set Text color on balance
|
||||
if($balance > 0){
|
||||
$balance_text_color = "text-danger font-weight-bold";
|
||||
}else{
|
||||
$balance_text_color = "";
|
||||
}
|
||||
|
||||
?>
|
||||
<tr>
|
||||
<td><a href="client.php?client_id=<?php echo $client_id; ?>"><?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 class="text-right text-monospace <?php echo $balance_text_color; ?>">$<?php echo number_format($balance,2); ?></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">
|
||||
<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="#editClientModal<?php echo $client_id; ?>">Edit</a>
|
||||
<a class="dropdown-item" href="post.php?delete_client=<?php echo $client_id; ?>">Delete</a>
|
||||
</div>
|
||||
</div>
|
||||
<?php include("edit_client_modal.php"); ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include("add_client_modal.php"); ?>
|
||||
|
||||
<?php include("footer.php");
|
||||
|
|
@ -0,0 +1,133 @@
|
|||
<?php include("header.php");
|
||||
|
||||
//Rebuild URL
|
||||
|
||||
$url_query_strings_sb = http_build_query(array_merge($_GET,array('sb' => $sb, 'o' => $o)));
|
||||
|
||||
if(isset($_GET['p'])){
|
||||
$p = intval($_GET['p']);
|
||||
$record_from = (($p)-1)*10;
|
||||
$record_to = 10;
|
||||
}else{
|
||||
$record_from = 0;
|
||||
$record_to = 10;
|
||||
$p = 1;
|
||||
}
|
||||
|
||||
if(isset($_GET['q'])){
|
||||
$q = $_GET['q'];
|
||||
}else{
|
||||
$q = "";
|
||||
}
|
||||
|
||||
if(!empty($_GET['sb'])){
|
||||
$sb = $_GET['sb'];
|
||||
}else{
|
||||
$sb = "company_id";
|
||||
}
|
||||
|
||||
if(isset($_GET['o'])){
|
||||
if($_GET['o'] == 'ASC'){
|
||||
$o = "ASC";
|
||||
$disp = "DESC";
|
||||
}else{
|
||||
$o = "DESC";
|
||||
$disp = "ASC";
|
||||
}
|
||||
}else{
|
||||
$o = "DESC";
|
||||
$disp = "ASC";
|
||||
}
|
||||
|
||||
$sql = mysqli_query($mysqli,"SELECT SQL_CALC_FOUND_ROWS * FROM companies, settings
|
||||
WHERE companies.company_id = settings.company_id
|
||||
AND companies.company_name LIKE '%$q%'
|
||||
ORDER BY $sb $o LIMIT $record_from, $record_to");
|
||||
|
||||
$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-1"><i class="fa fa-fw fa-building mr-2"></i>Companies</h6>
|
||||
<button type="button" class="btn btn-primary btn-sm mr-auto float-right" data-toggle="modal" data-target="#addCompanyModal"><i class="fas fa-fw fa-plus"></i></button>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form autocomplete="off">
|
||||
<div class="input-group">
|
||||
<input type="search" class="form-control col-md-4" name="q" value="<?php if(isset($q)){echo $q;} ?>" placeholder="Search Companies">
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-primary"><i class="fa fa-search"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-borderless table-hover">
|
||||
<thead class="text-dark">
|
||||
<tr>
|
||||
<th class="text-center"><a class="text-dark" href="?<?php echo $url_query_strings_sb; ?>&sb=company_name&o=<?php echo $disp; ?>">Name</a></th>
|
||||
<th class="text-center">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
|
||||
while($row = mysqli_fetch_array($sql)){
|
||||
$company_id = $row['company_id'];
|
||||
$company_name = $row['company_name'];
|
||||
$company_logo = $row['config_invoice_logo'];
|
||||
$initials = initials($company_name);
|
||||
|
||||
?>
|
||||
<tr>
|
||||
<td class="text-center">
|
||||
<a class="text-dark" href="#" data-toggle="modal" data-target="#editCompanyModal<?php echo $company_id; ?>">
|
||||
<?php if(!empty($company_logo)){ ?>
|
||||
<img height="48" width="48" class="img-fluid rounded-circle" src="<?php echo $company_logo; ?>">
|
||||
<?php }else{ ?>
|
||||
<span class="fa-stack fa-2x">
|
||||
<i class="fa fa-circle fa-stack-2x text-secondary"></i>
|
||||
<span class="fa fa-stack-1x text-white"><?php echo $initials; ?></span>
|
||||
</span>
|
||||
<br>
|
||||
<?php } ?>
|
||||
|
||||
<div class="text-secondary"><?php echo $company_name; ?></div>
|
||||
</a>
|
||||
</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">
|
||||
<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="#editCompanyModal<?php echo $company_id; ?>">Edit</a>
|
||||
<a class="dropdown-item" href="post.php?delete_company=<?php echo $company_id; ?>">Delete</a>
|
||||
</div>
|
||||
</div>
|
||||
<?php include("edit_company_modal.php"); ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<?php include("pagination.php"); ?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include("add_company_modal.php"); ?>
|
||||
|
||||
<?php include("footer.php");
|
||||
|
|
@ -1,11 +1,3 @@
|
|||
body {
|
||||
font-size: .875rem;
|
||||
|
||||
table.dT thead .sorting,
|
||||
table.dT thead .sorting_asc,
|
||||
table.dT thead .sorting_desc {
|
||||
background : none;
|
||||
}
|
||||
|
||||
|
||||
body{
|
||||
font-size: .875rem;
|
||||
}
|
||||
505
dashboard2.php
505
dashboard2.php
|
|
@ -1,505 +0,0 @@
|
|||
<?php include("header.php"); ?>
|
||||
|
||||
<?php
|
||||
|
||||
if(isset($_GET['year'])){
|
||||
$year = intval($_GET['year']);
|
||||
}else{
|
||||
$year = date('Y');
|
||||
}
|
||||
|
||||
//GET THE YEARS
|
||||
$sql_payment_years = mysqli_query($mysqli,"SELECT DISTINCT YEAR(payment_date) AS payment_year FROM payments ORDER BY payment_year DESC");
|
||||
|
||||
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('contact_id') AS num FROM contacts WHERE client_id = $client_id"));
|
||||
$num_contacts = $row['num'];
|
||||
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('location_id') AS num FROM locations WHERE client_id = $client_id"));
|
||||
$num_locations = $row['num'];
|
||||
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('asset_id') AS num FROM assets WHERE client_id = $client_id"));
|
||||
$num_assets = $row['num'];
|
||||
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('ticket_id') AS num FROM tickets WHERE client_id = $client_id"));
|
||||
$num_tickets = $row['num'];
|
||||
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('vendor_id') AS num FROM vendors WHERE client_id = $client_id"));
|
||||
$num_vendors = $row['num'];
|
||||
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('login_id') AS num FROM logins WHERE client_id = $client_id"));
|
||||
$num_logins = $row['num'];
|
||||
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('network_id') AS num FROM networks WHERE client_id = $client_id"));
|
||||
$num_networks = $row['num'];
|
||||
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('domain_id') AS num FROM domains WHERE client_id = $client_id"));
|
||||
$num_domains = $row['num'];
|
||||
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('software_id') AS num FROM software WHERE client_id = $client_id"));
|
||||
$num_software = $row['num'];
|
||||
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('invoice_id') AS num FROM invoices WHERE client_id = $client_id"));
|
||||
$num_invoices = $row['num'];
|
||||
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('quote_id') AS num FROM quotes WHERE client_id = $client_id"));
|
||||
$num_quotes = $row['num'];
|
||||
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('recurring_id') AS num FROM recurring WHERE client_id = $client_id"));
|
||||
$num_recurring = $row['num'];
|
||||
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('payment_id') AS num FROM payments, invoices WHERE payments.invoice_id = invoices.invoice_id AND invoices.client_id = $client_id"));
|
||||
$num_payments = $row['num'];
|
||||
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('file_id') AS num FROM files WHERE client_id = $client_id"));
|
||||
$num_files = $row['num'];
|
||||
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('note_id') AS num FROM notes WHERE client_id = $client_id"));
|
||||
$num_notes = $row['num'];
|
||||
|
||||
?>
|
||||
|
||||
<form>
|
||||
<select onchange="this.form.submit()" class="form-control mb-3" name="year">
|
||||
<?php
|
||||
|
||||
while($row = mysqli_fetch_array($sql_payment_years)){
|
||||
$payment_year = $row['payment_year'];
|
||||
?>
|
||||
<option <?php if($year == $payment_year){ ?> selected <?php } ?> > <?php echo $payment_year; ?></option>
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
</select>
|
||||
</form>
|
||||
|
||||
<!-- Icon Cards-->
|
||||
<div class="row">
|
||||
<div class="col-xl-4 col-sm-6 mb-3">
|
||||
<div class="card text-white bg-primary o-hidden h-100">
|
||||
<div class="card-body">
|
||||
<div class="card-body-icon">
|
||||
<i class="fas fa-fw fa-money-check"></i>
|
||||
</div>
|
||||
<div class="mr-5">Total Incomes <h1>$<?php echo number_format($total_income,2); ?></h1></div>
|
||||
<hr>
|
||||
Recievables: $<?php echo number_format($recievables,2); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xl-4 col-sm-6 mb-3">
|
||||
<div class="card text-white bg-danger o-hidden h-100">
|
||||
<div class="card-body">
|
||||
<div class="card-body-icon">
|
||||
<i class="fas fa-fw fa-shopping-cart"></i>
|
||||
</div>
|
||||
<div class="mr-5">Total Expenses <h1>$<?php echo number_format($total_expenses,2); ?></h1></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xl-4 col-sm-6 mb-3">
|
||||
<div class="card text-white bg-success o-hidden h-100">
|
||||
<div class="card-body">
|
||||
<div class="card-body-icon">
|
||||
<i class="fas fa-fw fa-heart"></i>
|
||||
</div>
|
||||
<div class="mr-5">Total Profit <h1>$<?php echo number_format($profit,2); ?></h1></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-12">
|
||||
<!-- Area Chart Example-->
|
||||
<div class="card mb-3">
|
||||
<div class="card-header"><i class="fas fa-fw fa-chart-area"></i> Cash Flow</div>
|
||||
<div class="card-body">
|
||||
<canvas id="myAreaChart" width="100%" height="25"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-4">
|
||||
<div class="card mb-3">
|
||||
<div class="card-header">
|
||||
<i class="fas fa-chart-pie"></i>
|
||||
Income By Category
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<canvas id="incomeByCategoryPieChart" width="100%" height="60"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-4">
|
||||
<div class="card mb-3">
|
||||
<div class="card-header">
|
||||
<i class="fas fa-chart-pie"></i>
|
||||
Expense By Category
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<canvas id="expenseByCategoryPieChart" width="100%" height="60"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-4">
|
||||
<div class="card mb-3">
|
||||
<div class="card-header">
|
||||
<i class="fas fa-chart-pie"></i>
|
||||
Expense By Vendor
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<canvas id="expenseByVendorPieChart" width="100%" height="60"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-md-4">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
Account Balance
|
||||
</div>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-borderless">
|
||||
<tbody>
|
||||
<?php
|
||||
while($row = mysqli_fetch_array($sql_accounts)){
|
||||
$account_id = $row['account_id'];
|
||||
$account_name = $row['account_name'];
|
||||
$opening_balance = $row['opening_balance'];
|
||||
|
||||
?>
|
||||
<tr>
|
||||
<td><?php echo $account_name; ?></a></td>
|
||||
<?php
|
||||
$sql2 = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS total_payments FROM payments WHERE account_id = $account_id");
|
||||
$row2 = mysqli_fetch_array($sql2);
|
||||
|
||||
$sql3 = mysqli_query($mysqli,"SELECT SUM(expense_amount) AS total_expenses FROM expenses WHERE account_id = $account_id");
|
||||
$row3 = mysqli_fetch_array($sql3);
|
||||
|
||||
$balance = $opening_balance + $row2['total_payments'] - $row3['total_expenses'];
|
||||
if($balance == ''){
|
||||
$balance = '0.00';
|
||||
}
|
||||
?>
|
||||
|
||||
<td class="text-right text-monospace">$<?php echo number_format($balance,2); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- .col -->
|
||||
<div class="col-md-4">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
Latest Payments
|
||||
</div>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-borderless">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Date</th>
|
||||
<th>Customer</th>
|
||||
<th>Invoice</th>
|
||||
<th class="text-right">Amount</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
while($row = mysqli_fetch_array($sql_latest_income_payments)){
|
||||
$payment_date = $row['payment_date'];
|
||||
$payment_amount = $row['payment_amount'];
|
||||
$invoice_number = $row['invoice_number'];
|
||||
$client_name = $row['client_name'];
|
||||
?>
|
||||
<tr>
|
||||
<td><?php echo $payment_date; ?></td>
|
||||
<td><?php echo $client_name; ?></td>
|
||||
<td><?php echo $invoice_number; ?></td>
|
||||
<td class="text-right text-monospace">$<?php echo number_format($payment_amount,2); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- .col -->
|
||||
<div class="col-md-4">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
Latest Expenses
|
||||
</div>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-borderless">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Date</th>
|
||||
<th>Vendor</th>
|
||||
<th>Category</th>
|
||||
<th class="text-right">Amount</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
while($row = mysqli_fetch_array($sql_latest_expenses)){
|
||||
$expense_date = $row['expense_date'];
|
||||
$expense_amount = $row['expense_amount'];
|
||||
$vendor_name = $row['vendor_name'];
|
||||
$category_name = $row['category_name'];
|
||||
|
||||
?>
|
||||
<tr>
|
||||
<td><?php echo $expense_date; ?></td>
|
||||
<td><?php echo $vendor_name; ?></td>
|
||||
<td><?php echo $category_name; ?></td>
|
||||
<td class="text-right text-monospace">$<?php echo number_format($expense_amount,2); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div> <!-- .col -->
|
||||
</div> <!-- row -->
|
||||
|
||||
|
||||
|
||||
<?php include("footer.php"); ?>
|
||||
<script>
|
||||
// Set new default font family and font color to mimic Bootstrap's default styling
|
||||
Chart.defaults.global.defaultFontFamily = '-apple-system,system-ui,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif';
|
||||
Chart.defaults.global.defaultFontColor = '#292b2c';
|
||||
|
||||
// Area Chart Example
|
||||
var ctx = document.getElementById("myAreaChart");
|
||||
var myLineChart = new Chart(ctx, {
|
||||
type: 'line',
|
||||
data: {
|
||||
labels: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Nov", "Dec"],
|
||||
datasets: [{
|
||||
label: "Income",
|
||||
lineTension: 0.3,
|
||||
backgroundColor: "rgba(2,117,216,0.2)",
|
||||
borderColor: "rgba(2,117,216,1)",
|
||||
pointRadius: 5,
|
||||
pointBackgroundColor: "rgba(2,117,216,1)",
|
||||
pointBorderColor: "rgba(255,255,255,0.8)",
|
||||
pointHoverRadius: 5,
|
||||
pointHoverBackgroundColor: "rgba(2,117,216,1)",
|
||||
pointHitRadius: 50,
|
||||
pointBorderWidth: 2,
|
||||
data: [
|
||||
<?php
|
||||
for($month = 1; $month<=12; $month++) {
|
||||
$sql_payments = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS payment_amount_for_month FROM payments, invoices WHERE payments.invoice_id = invoices.invoice_id AND YEAR(payment_date) = $year AND MONTH(payment_date) = $month");
|
||||
$row = mysqli_fetch_array($sql_payments);
|
||||
$income_for_month = $row['payment_amount_for_month'];
|
||||
if($income_for_month > 0 AND $income_for_month > $largest_income_month){
|
||||
$largest_income_month = $income_for_month;
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
<?php echo "$income_for_month,"; ?>
|
||||
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
],
|
||||
}],
|
||||
},
|
||||
options: {
|
||||
scales: {
|
||||
xAxes: [{
|
||||
time: {
|
||||
unit: 'date'
|
||||
},
|
||||
gridLines: {
|
||||
display: false
|
||||
},
|
||||
ticks: {
|
||||
maxTicksLimit: 12
|
||||
}
|
||||
}],
|
||||
yAxes: [{
|
||||
ticks: {
|
||||
min: 0,
|
||||
max: <?php echo roundUpToNearestMultiple($largest_income_month); ?>,
|
||||
maxTicksLimit: 5
|
||||
},
|
||||
gridLines: {
|
||||
color: "rgba(0, 0, 0, .125)",
|
||||
}
|
||||
}],
|
||||
},
|
||||
legend: {
|
||||
display: false
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Set new default font family and font color to mimic Bootstrap's default styling
|
||||
Chart.defaults.global.defaultFontFamily = '-apple-system,system-ui,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif';
|
||||
Chart.defaults.global.defaultFontColor = '#292b2c';
|
||||
|
||||
// Pie Chart Example
|
||||
var ctx = document.getElementById("incomeByCategoryPieChart");
|
||||
var myPieChart = new Chart(ctx, {
|
||||
type: 'pie',
|
||||
data: {
|
||||
labels: [
|
||||
<?php
|
||||
$sql_categories = mysqli_query($mysqli,"SELECT DISTINCT category_name, categories.category_id FROM categories, invoices WHERE invoices.category_id = categories.category_id AND invoice_status = 'Paid' AND YEAR(invoice_date) = $year");
|
||||
while($row = mysqli_fetch_array($sql_categories)){
|
||||
$category_name = $row['category_name'];
|
||||
echo "\"$category_name\",";
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
],
|
||||
datasets: [{
|
||||
data: [
|
||||
<?php
|
||||
$sql_categories = mysqli_query($mysqli,"SELECT DISTINCT category_name, categories.category_id FROM categories, invoices WHERE invoices.category_id = categories.category_id AND invoice_status = 'Paid' AND YEAR(invoice_date) = $year");
|
||||
while($row = mysqli_fetch_array($sql_categories)){
|
||||
$category_id = $row['category_id'];
|
||||
|
||||
$sql_invoices = mysqli_query($mysqli,"SELECT SUM(invoice_amount) AS income_amount_for_year FROM invoices WHERE category_id = $category_id AND YEAR(invoice_date) = $year");
|
||||
$row = mysqli_fetch_array($sql_invoices);
|
||||
$income_amount_for_year = $row['income_amount_for_year'];
|
||||
echo "$income_amount_for_year,";
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
],
|
||||
backgroundColor: [
|
||||
<?php
|
||||
$sql_categories = mysqli_query($mysqli,"SELECT DISTINCT category_name, categories.category_id, category_color FROM categories, invoices WHERE invoices.category_id = categories.category_id AND YEAR(invoice_date) = $year");
|
||||
while($row = mysqli_fetch_array($sql_categories)){
|
||||
$category_color = $row['category_color'];
|
||||
echo "\"$category_color\",";
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
],
|
||||
}],
|
||||
},
|
||||
});
|
||||
|
||||
// Set new default font family and font color to mimic Bootstrap's default styling
|
||||
Chart.defaults.global.defaultFontFamily = '-apple-system,system-ui,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif';
|
||||
Chart.defaults.global.defaultFontColor = '#292b2c';
|
||||
|
||||
// Pie Chart Example
|
||||
var ctx = document.getElementById("expenseByCategoryPieChart");
|
||||
var myPieChart = new Chart(ctx, {
|
||||
type: 'pie',
|
||||
data: {
|
||||
labels: [
|
||||
<?php
|
||||
$sql_categories = mysqli_query($mysqli,"SELECT DISTINCT category_name, categories.category_id FROM categories, expenses WHERE expenses.category_id = categories.category_id AND YEAR(expense_date) = $year");
|
||||
while($row = mysqli_fetch_array($sql_categories)){
|
||||
$category_name = $row['category_name'];
|
||||
echo "\"$category_name\",";
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
],
|
||||
datasets: [{
|
||||
data: [
|
||||
<?php
|
||||
$sql_categories = mysqli_query($mysqli,"SELECT DISTINCT category_name, categories.category_id FROM categories, expenses WHERE expenses.category_id = categories.category_id AND YEAR(expense_date) = $year");
|
||||
while($row = mysqli_fetch_array($sql_categories)){
|
||||
$category_id = $row['category_id'];
|
||||
|
||||
$sql_expenses = mysqli_query($mysqli,"SELECT SUM(expense_amount) AS expense_amount_for_year FROM expenses WHERE category_id = $category_id AND YEAR(expense_date) = $year");
|
||||
$row = mysqli_fetch_array($sql_expenses);
|
||||
$expense_amount_for_year = $row['expense_amount_for_year'];
|
||||
echo "$expense_amount_for_year,";
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
],
|
||||
backgroundColor: [
|
||||
<?php
|
||||
$sql_categories = mysqli_query($mysqli,"SELECT DISTINCT category_name, category_color FROM categories, expenses WHERE expenses.category_id = categories.category_id AND YEAR(expense_date) = $year");
|
||||
while($row = mysqli_fetch_array($sql_categories)){
|
||||
$category_color = $row['category_color'];
|
||||
echo "\"$category_color\",";
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
],
|
||||
}],
|
||||
},
|
||||
});
|
||||
|
||||
// Pie Chart Example
|
||||
var ctx = document.getElementById("expenseByVendorPieChart");
|
||||
var myPieChart = new Chart(ctx, {
|
||||
type: 'pie',
|
||||
data: {
|
||||
labels: [
|
||||
<?php
|
||||
$sql_vendors = mysqli_query($mysqli,"SELECT DISTINCT vendor_name, vendors.vendor_id FROM vendors, expenses WHERE expenses.vendor_id = vendors.vendor_id AND YEAR(expense_date) = $year");
|
||||
while($row = mysqli_fetch_array($sql_vendors)){
|
||||
$vendor_name = $row['vendor_name'];
|
||||
echo "\"$vendor_name\",";
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
],
|
||||
datasets: [{
|
||||
data: [
|
||||
<?php
|
||||
$sql_vendors = mysqli_query($mysqli,"SELECT DISTINCT vendor_name, vendors.vendor_id FROM vendors, expenses WHERE expenses.vendor_id = vendors.vendor_id AND YEAR(expense_date) = $year");
|
||||
while($row = mysqli_fetch_array($sql_vendors)){
|
||||
$vendor_id = $row['vendor_id'];
|
||||
|
||||
$sql_expenses = mysqli_query($mysqli,"SELECT SUM(expense_amount) AS expense_amount_for_year FROM expenses WHERE vendor_id = $vendor_id AND YEAR(expense_date) = $year");
|
||||
$row = mysqli_fetch_array($sql_expenses);
|
||||
$expense_amount_for_year = $row['expense_amount_for_year'];
|
||||
echo "$expense_amount_for_year,";
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
],
|
||||
backgroundColor: [
|
||||
<?php
|
||||
$sql_categories = mysqli_query($mysqli,"SELECT DISTINCT category_name, category_color FROM categories, expenses WHERE expenses.category_id = categories.category_id AND YEAR(expense_date) = $year");
|
||||
while($row = mysqli_fetch_array($sql_categories)){
|
||||
$category_color = $row['category_color'];
|
||||
echo "\"$category_color\",";
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
],
|
||||
}],
|
||||
},
|
||||
});
|
||||
|
||||
</script>
|
||||
|
|
@ -1,158 +0,0 @@
|
|||
<?php include("header.php"); ?>
|
||||
|
||||
<?php
|
||||
|
||||
if(isset($_GET['orderby'])){
|
||||
$orderby = "ORDER BY " . $_GET['orderby'];
|
||||
}
|
||||
|
||||
if(isset($_GET['order'])){
|
||||
$order = $_GET['order'];
|
||||
}
|
||||
|
||||
if(isset($_GET['search'])){
|
||||
$search = $_GET['search'];
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<?php $sql = mysqli_query($mysqli,"SELECT * FROM clients WHERE client_name LIKE '%$search%' $orderby $order LIMIT 10"); ?>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-8">
|
||||
<h6 class="ml-3"><i class="fa fa-users mr-2"></i>Clients</h6>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
|
||||
<form>
|
||||
<div class="form-row">
|
||||
<div class="form-group col-md-3">
|
||||
<div class="input-group">
|
||||
<input type="text" class="form-control form-control-sm" placeholder="Search clients..." name="search">
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-sm btn-primary" type="submit"><i class="fa fa-search"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group col-md-2">
|
||||
<div class="input-group">
|
||||
<select class="form-control form-control-sm" name="orderby">
|
||||
<option>- Sort By -</option>
|
||||
<option value="client_name">Client Name</option>
|
||||
</select>
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-sm btn-secondary" type="submit" name="sort" value="ASC"><i class="fa fa-arrow-down"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-7">
|
||||
<button type="button" class="btn btn-sm btn-primary float-right" data-toggle="modal" data-target="#addClientModal"><i class="fas fa-fw fa-user-plus"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-borderless table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><a href="<?php $_SERVER['PHP_SELF']; ?>?orderby=client_name&order=asc">Name <i class="fa fa-sort-alpha-down"></i></a></th>
|
||||
<th><a href="?orderby=client_email">Email</a></th>
|
||||
<th><a href="?sortby=client_phone">Phone</a></th>
|
||||
<th class="text-right">Balance</th>
|
||||
<th class="text-center">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
|
||||
while($row = mysqli_fetch_array($sql)){
|
||||
$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_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_email = $row['client_email'];
|
||||
$client_website = $row['client_website'];
|
||||
$client_net_terms = $row['client_net_terms'];
|
||||
|
||||
//Add up all the payments for the invoice and get the total amount paid to the invoice
|
||||
$sql_invoice_amounts = mysqli_query($mysqli,"SELECT SUM(invoice_amount) AS invoice_amounts FROM invoices WHERE client_id = $client_id AND invoice_status NOT LIKE 'Draft'");
|
||||
$row = mysqli_fetch_array($sql_invoice_amounts);
|
||||
|
||||
$invoice_amounts = $row['invoice_amounts'];
|
||||
|
||||
$sql_amount_paid = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS amount_paid FROM payments, invoices WHERE payments.invoice_id = invoices.invoice_id AND invoices.client_id = $client_id");
|
||||
$row = mysqli_fetch_array($sql_amount_paid);
|
||||
|
||||
$amount_paid = $row['amount_paid'];
|
||||
|
||||
$balance = $invoice_amounts - $amount_paid;
|
||||
//set Text color on balance
|
||||
if($balance > 0){
|
||||
$balance_text_color = "text-danger";
|
||||
}
|
||||
|
||||
?>
|
||||
<tr>
|
||||
<td><a href="client.php?client_id=<?php echo $client_id; ?>"><?php echo "$client_name"; ?></a></td>
|
||||
<td><a href="mailto:<?php echo$email; ?>"><?php echo "$client_email"; ?></a></td>
|
||||
<td><?php echo "$client_phone"; ?></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">
|
||||
<button class="btn btn-secondary btn-sm" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<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="#editClientModal<?php echo $client_id; ?>">Edit</a>
|
||||
<a class="dropdown-item" href="post.php?delete_client=<?php echo $client_id; ?>">Delete</a>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
include("edit_client_modal.php");
|
||||
}
|
||||
?>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<nav aria-label="Page navigation example">
|
||||
<ul class="pagination justify-content-end">
|
||||
<li class="page-item disabled">
|
||||
<a class="page-link" href="#" tabindex="-1" aria-disabled="true">Previous</a>
|
||||
</li>
|
||||
<li class="page-item active"><a class="page-link" href="#">1</a></li>
|
||||
<li class="page-item"><a class="page-link" href="#">2</a></li>
|
||||
<li class="page-item"><a class="page-link" href="#">3</a></li>
|
||||
<li class="page-item"><a class="page-link" href="#">4</a></li>
|
||||
<li class="page-item"><a class="page-link" href="#">5</a></li>
|
||||
<li class="page-item">
|
||||
<a class="page-link" href="#">Next</a>
|
||||
</li>
|
||||
</ul>
|
||||
</nav>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<?php include("add_client_modal.php"); ?>
|
||||
|
||||
<?php include("footer.php");
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
<div class="modal" id="editCompanyModal<?php echo $company_id; ?>" 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-user-plus mr-2"></i><?php echo $company_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="company_id" value="<?php echo $company_id; ?>">
|
||||
<div class="modal-body bg-white">
|
||||
|
||||
<div class="form-group">
|
||||
<label>Name <strong class="text-danger">*</strong></label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-building"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="name" placeholder="Company Name" value="<?php echo $company_name; ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer bg-white">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
|
||||
<button type="submit" name="edit_company" class="btn btn-primary">Save</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -16,7 +16,7 @@
|
|||
<meta name="description" content="">
|
||||
<meta name="author" content="">
|
||||
|
||||
<title><?php echo $config_company_name; ?></title>
|
||||
<title><?php echo $company_name; ?></title>
|
||||
|
||||
<!-- Custom fonts for this template-->
|
||||
<link href="vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css">
|
||||
|
|
|
|||
146
guest_post.php
146
guest_post.php
|
|
@ -17,32 +17,49 @@ if(isset($_GET['pdf_invoice'], $_GET['url_key'])){
|
|||
AND invoices.invoice_url_key = '$url_key'"
|
||||
);
|
||||
|
||||
$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_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'];
|
||||
|
||||
if(mysqli_num_rows($sql) == 1){
|
||||
|
||||
$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_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'];
|
||||
$company_id = $row['company_id'];
|
||||
|
||||
$sql_company = mysqli_query($mysqli,"SELECT * FROM settings, companies WHERE settings.company_id = companies.company_id AND companies.company_id = $company_id");
|
||||
$row = mysqli_fetch_array($sql_company);
|
||||
|
||||
$company_name = $row['company_name'];
|
||||
$config_company_address = $row['config_company_address'];
|
||||
$config_company_city = $row['config_company_city'];
|
||||
$config_company_state = $row['config_company_state'];
|
||||
$config_company_zip = $row['config_company_zip'];
|
||||
$config_company_phone = $row['config_company_phone'];
|
||||
if(strlen($config_company_phone)>2){
|
||||
$config_company_phone = substr($row['config_company_phone'],0,3)."-".substr($row['config_company_phone'],3,3)."-".substr($row['config_company_phone'],6,4);
|
||||
}
|
||||
$config_company_email = $row['config_company_email'];
|
||||
$config_invoice_logo = $row['config_invoice_logo'];
|
||||
|
||||
//Mark downloaded in history
|
||||
mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = '$invoice_status', history_description = 'Invoice downloaded', history_created_at = NOW(), invoice_id = $invoice_id");
|
||||
mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = '$invoice_status', history_description = 'Invoice downloaded', history_created_at = NOW(), invoice_id = $invoice_id, company_id = $company_id");
|
||||
|
||||
$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");
|
||||
|
||||
|
|
@ -123,8 +140,8 @@ if(isset($_GET['pdf_invoice'], $_GET['url_key'])){
|
|||
<htmlpageheader name="myheader">
|
||||
<table width="100%"><tr>
|
||||
<td width="15%"><img width="75" height="75" src=" /'.$config_invoice_logo.' "></img></td>
|
||||
<td width="50%"><span style="font-weight: bold; font-size: 14pt;"> '.$config_company_name.' </span><br />' .$config_company_address.' <br /> '.$config_company_city.' '.$config_company_state.' '.$config_company_zip.'<br /> '.$config_company_phone.' </td>
|
||||
<td width="35%" style="text-align: right;">Invoice No.<br /><span style="font-weight: bold; font-size: 12pt;"> INV-'.$invoice_number.' </span></td>
|
||||
<td width="50%"><span style="font-weight: bold; font-size: 14pt;"> '.$company_name.' </span><br />' .$config_company_address.' <br /> '.$config_company_city.' '.$config_company_state.' '.$config_company_zip.'<br /> '.$config_company_phone.' </td>
|
||||
<td width="35%" style="text-align: right;">Invoice No.<br /><span style="font-weight: bold; font-size: 12pt;"> '.$invoice_number.' </span></td>
|
||||
</tr></table>
|
||||
</htmlpageheader>
|
||||
<htmlpagefooter name="myfooter">
|
||||
|
|
@ -194,8 +211,8 @@ if(isset($_GET['pdf_invoice'], $_GET['url_key'])){
|
|||
]);
|
||||
|
||||
$mpdf->SetProtection(array('print'));
|
||||
$mpdf->SetTitle("$config_company_name - Invoice");
|
||||
$mpdf->SetAuthor("$config_company_name");
|
||||
$mpdf->SetTitle("$company_name - Invoice");
|
||||
$mpdf->SetAuthor("$company_name");
|
||||
if($invoice_status == 'Paid'){
|
||||
$mpdf->SetWatermarkText("Paid");
|
||||
}
|
||||
|
|
@ -204,7 +221,7 @@ if(isset($_GET['pdf_invoice'], $_GET['url_key'])){
|
|||
$mpdf->watermarkTextAlpha = 0.1;
|
||||
$mpdf->SetDisplayMode('fullpage');
|
||||
$mpdf->WriteHTML($html);
|
||||
$mpdf->Output("$invoice_date-$config_company_name-Invoice$invoice_number.pdf",'D');
|
||||
$mpdf->Output("$invoice_date-$company_name-Invoice$invoice_number.pdf",'D');
|
||||
|
||||
}else{
|
||||
echo "GTFO!!!";
|
||||
|
|
@ -222,28 +239,44 @@ if(isset($_GET['pdf_quote'], $_GET['url_key'])){
|
|||
AND quotes.quote_url_key = '$url_key'"
|
||||
);
|
||||
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$quote_id = $row['quote_id'];
|
||||
$quote_number = $row['quote_number'];
|
||||
$quote_status = $row['quote_status'];
|
||||
$quote_date = $row['quote_date'];
|
||||
$quote_amount = $row['quote_amount'];
|
||||
$quote_note = $row['quote_note'];
|
||||
$quote_url_key = $row['quote_url_key'];
|
||||
$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'];
|
||||
|
||||
if(mysqli_num_rows($sql) == 1){
|
||||
$row = mysqli_fetch_array($sql);
|
||||
|
||||
$quote_id = $row['quote_id'];
|
||||
$quote_number = $row['quote_number'];
|
||||
$quote_status = $row['quote_status'];
|
||||
$quote_date = $row['quote_date'];
|
||||
$quote_amount = $row['quote_amount'];
|
||||
$quote_note = $row['quote_note'];
|
||||
$quote_url_key = $row['quote_url_key'];
|
||||
$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'];
|
||||
$company_id = $row['company_id'];
|
||||
|
||||
$sql_company = mysqli_query($mysqli,"SELECT * FROM settings, companies WHERE settings.company_id = companies.company_id AND companies.company_id = $company_id");
|
||||
$row = mysqli_fetch_array($sql_company);
|
||||
|
||||
$company_name = $row['company_name'];
|
||||
$config_company_address = $row['config_company_address'];
|
||||
$config_company_city = $row['config_company_city'];
|
||||
$config_company_state = $row['config_company_state'];
|
||||
$config_company_zip = $row['config_company_zip'];
|
||||
$config_company_phone = $row['config_company_phone'];
|
||||
if(strlen($config_company_phone)>2){
|
||||
$config_company_phone = substr($row['config_company_phone'],0,3)."-".substr($row['config_company_phone'],3,3)."-".substr($row['config_company_phone'],6,4);
|
||||
}
|
||||
$config_company_email = $row['config_company_email'];
|
||||
$config_invoice_logo = $row['config_invoice_logo'];
|
||||
|
||||
$sql_items = mysqli_query($mysqli,"SELECT * FROM invoice_items WHERE quote_id = $quote_id ORDER BY item_id ASC");
|
||||
|
||||
|
|
@ -316,8 +349,8 @@ if(isset($_GET['pdf_quote'], $_GET['url_key'])){
|
|||
<htmlpageheader name="myheader">
|
||||
<table width="100%"><tr>
|
||||
<td width="15%"><img width="75" height="75" src=" /'.$config_invoice_logo.' "></img></td>
|
||||
<td width="50%"><span style="font-weight: bold; font-size: 14pt;"> '.$config_company_name.' </span><br />' .$config_company_address.' <br /> '.$config_company_city.' '.$config_company_state.' '.$config_company_zip.'<br /> '.$config_company_phone.' </td>
|
||||
<td width="35%" style="text-align: right;">Quote No.<br /><span style="font-weight: bold; font-size: 12pt;"> QUO-'.$quote_number.' </span></td>
|
||||
<td width="50%"><span style="font-weight: bold; font-size: 14pt;"> '.$company_name.' </span><br />' .$config_company_address.' <br /> '.$config_company_city.' '.$config_company_state.' '.$config_company_zip.'<br /> '.$config_company_phone.' </td>
|
||||
<td width="35%" style="text-align: right;">Quote No.<br /><span style="font-weight: bold; font-size: 12pt;"> '.$quote_number.' </span></td>
|
||||
</tr></table>
|
||||
</htmlpageheader>
|
||||
<htmlpagefooter name="myfooter">
|
||||
|
|
@ -377,15 +410,15 @@ if(isset($_GET['pdf_quote'], $_GET['url_key'])){
|
|||
'margin_footer' => 10
|
||||
]);
|
||||
$mpdf->SetProtection(array('print'));
|
||||
$mpdf->SetTitle("$config_company_name - Quote");
|
||||
$mpdf->SetAuthor("$config_company_name");
|
||||
$mpdf->SetTitle("$company_name - Quote");
|
||||
$mpdf->SetAuthor("$company_name");
|
||||
$mpdf->SetWatermarkText("Quote");
|
||||
$mpdf->showWatermarkText = true;
|
||||
$mpdf->watermark_font = 'DejaVuSansCondensed';
|
||||
$mpdf->watermarkTextAlpha = 0.1;
|
||||
$mpdf->SetDisplayMode('fullpage');
|
||||
$mpdf->WriteHTML($html);
|
||||
$mpdf->Output("$quote_date-$config_company_name-Quote$quote_number.pdf",'D');
|
||||
$mpdf->Output("$quote_date-$company_name-Quote$quote_number.pdf",'D');
|
||||
|
||||
}else{
|
||||
echo "GTFO!!!";
|
||||
|
|
@ -404,10 +437,9 @@ if(isset($_GET['approve_quote'], $_GET['url_key'])){
|
|||
|
||||
if(mysqli_num_rows($sql) == 1){
|
||||
|
||||
|
||||
mysqli_query($mysqli,"UPDATE quotes SET quote_status = 'Approved' WHERE quote_id = $quote_id");
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = 'Approved', history_description = 'Client approved Quote!', history_created_at = NOW(), quote_id = $quote_id");
|
||||
mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = 'Approved', history_description = 'Client approved Quote!', history_created_at = NOW(), quote_id = $quote_id, company_id = $company_id");
|
||||
|
||||
$_SESSION['alert_message'] = "Quote approved";
|
||||
|
||||
|
|
@ -432,7 +464,7 @@ if(isset($_GET['reject_quote'], $_GET['url_key'])){
|
|||
|
||||
mysqli_query($mysqli,"UPDATE quotes SET quote_status = 'Rejected' WHERE quote_id = $quote_id");
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = 'Rejected', history_description = 'Client rejected Quote!', history_created_at = NOW(), quote_id = $quote_id");
|
||||
mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = 'Rejected', history_description = 'Client rejected Quote!', history_created_at = NOW(), quote_id = $quote_id, company_id = $company_id");
|
||||
|
||||
$_SESSION['alert_message'] = "Quote rejected";
|
||||
|
||||
|
|
|
|||
|
|
@ -13,36 +13,51 @@ if(isset($_GET['invoice_id'], $_GET['url_key'])){
|
|||
AND invoices.invoice_url_key = '$url_key'"
|
||||
);
|
||||
|
||||
$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_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;
|
||||
}
|
||||
|
||||
if(mysqli_num_rows($sql) == 1){
|
||||
|
||||
|
||||
$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_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;
|
||||
}
|
||||
$company_id = $row['company_id'];
|
||||
|
||||
$sql_company = mysqli_query($mysqli,"SELECT * FROM settings, companies WHERE settings.company_id = companies.company_id AND companies.company_id = $company_id");
|
||||
$row = mysqli_fetch_array($sql_company);
|
||||
|
||||
$company_name = $row['company_name'];
|
||||
$config_company_address = $row['config_company_address'];
|
||||
$config_company_city = $row['config_company_city'];
|
||||
$config_company_state = $row['config_company_state'];
|
||||
$config_company_zip = $row['config_company_zip'];
|
||||
$config_company_phone = $row['config_company_phone'];
|
||||
if(strlen($config_company_phone)>2){
|
||||
$config_company_phone = substr($row['config_company_phone'],0,3)."-".substr($row['config_company_phone'],3,3)."-".substr($row['config_company_phone'],6,4);
|
||||
}
|
||||
$config_company_email = $row['config_company_email'];
|
||||
|
||||
//Mark viewed in history
|
||||
mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = '$invoice_status', history_description = 'Invoice viewed', history_created_at = NOW(), invoice_id = $invoice_id");
|
||||
mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = '$invoice_status', history_description = 'Invoice viewed', history_created_at = NOW(), invoice_id = $invoice_id, company_id = $company_id");
|
||||
|
||||
|
||||
$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");
|
||||
|
|
@ -89,7 +104,7 @@ if(isset($_GET['invoice_id'], $_GET['url_key'])){
|
|||
<?php
|
||||
if($invoice_status != "Paid" and $invoice_status != "Cancelled" and $invoice_status != "Draft"){
|
||||
?>
|
||||
<a class="btn btn-success" href="post.php?pdf_invoice=<?php echo $invoice_id; ?>"><i class="fa fa-fw fa-credit-card"></i> Pay Online</a>
|
||||
<a class="btn btn-success" href="guest_pay.php?invoice_id=<?php echo $invoice_id; ?>"><i class="fa fa-fw fa-credit-card"></i> Pay Online</a>
|
||||
<?php } ?>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -105,7 +120,7 @@ if(isset($_GET['invoice_id'], $_GET['url_key'])){
|
|||
</div>
|
||||
<div class="card-body">
|
||||
<ul class="list-unstyled">
|
||||
<li><strong><?php echo $config_company_name; ?></strong></li>
|
||||
<li><strong><?php echo $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>
|
||||
|
|
@ -137,7 +152,7 @@ if(isset($_GET['invoice_id'], $_GET['url_key'])){
|
|||
</div>
|
||||
<div class="card-body">
|
||||
<ul class="list-unstyled">
|
||||
<li class="mb-1"><strong>Invoice Number:</strong> <div class="float-right">INV-<?php echo $invoice_number; ?></div></li>
|
||||
<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>
|
||||
|
|
|
|||
|
|
@ -13,35 +13,51 @@ if(isset($_GET['quote_id'], $_GET['url_key'])){
|
|||
AND quotes.quote_url_key = '$url_key'"
|
||||
);
|
||||
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$quote_id = $row['quote_id'];
|
||||
$quote_number = $row['quote_number'];
|
||||
$quote_status = $row['quote_status'];
|
||||
$quote_date = $row['quote_date'];
|
||||
$quote_amount = $row['quote_amount'];
|
||||
$quote_note = $row['quote_note'];
|
||||
$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;
|
||||
}
|
||||
|
||||
if(mysqli_num_rows($sql) == 1){
|
||||
|
||||
$row = mysqli_fetch_array($sql);
|
||||
|
||||
$quote_id = $row['quote_id'];
|
||||
$quote_number = $row['quote_number'];
|
||||
$quote_status = $row['quote_status'];
|
||||
$quote_date = $row['quote_date'];
|
||||
$quote_amount = $row['quote_amount'];
|
||||
$quote_note = $row['quote_note'];
|
||||
$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;
|
||||
}
|
||||
$company_id = $row['company_id'];
|
||||
|
||||
$sql_company = mysqli_query($mysqli,"SELECT * FROM settings, companies WHERE settings.company_id = companies.company_id AND companies.company_id = $company_id");
|
||||
$row = mysqli_fetch_array($sql_company);
|
||||
|
||||
$company_name = $row['company_name'];
|
||||
$config_company_address = $row['config_company_address'];
|
||||
$config_company_city = $row['config_company_city'];
|
||||
$config_company_state = $row['config_company_state'];
|
||||
$config_company_zip = $row['config_company_zip'];
|
||||
$config_company_phone = $row['config_company_phone'];
|
||||
if(strlen($config_company_phone)>2){
|
||||
$config_company_phone = substr($row['config_company_phone'],0,3)."-".substr($row['config_company_phone'],3,3)."-".substr($row['config_company_phone'],6,4);
|
||||
}
|
||||
$config_company_email = $row['config_company_email'];
|
||||
|
||||
//Mark viewed in history
|
||||
mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = '$quote_status', history_description = 'Quote viewed', history_created_at = NOW(), quote_id = $quote_id");
|
||||
mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = '$quote_status', history_description = 'Quote viewed', history_created_at = NOW(), quote_id = $quote_id, company_id = $company_id");
|
||||
|
||||
//Set Badge color based off of quote status
|
||||
if($quote_status == "Sent"){
|
||||
|
|
@ -86,7 +102,7 @@ if(isset($_GET['quote_id'], $_GET['url_key'])){
|
|||
</div>
|
||||
<div class="card-body">
|
||||
<ul class="list-unstyled">
|
||||
<li><strong><?php echo $config_company_name; ?></strong></li>
|
||||
<li><strong><?php echo $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>
|
||||
|
|
@ -118,7 +134,7 @@ if(isset($_GET['quote_id'], $_GET['url_key'])){
|
|||
</div>
|
||||
<div class="card-body">
|
||||
<ul class="list-unstyled">
|
||||
<li class="mb-1"><strong>Quote Number:</strong> <div class="float-right">QUO-<?php echo $quote_number; ?></div></li>
|
||||
<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>
|
||||
|
|
|
|||
209
invoices_old.php
209
invoices_old.php
|
|
@ -1,209 +0,0 @@
|
|||
<?php include("header.php"); ?>
|
||||
|
||||
<?php
|
||||
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('invoice_id') AS num FROM invoices WHERE invoice_status = 'Sent'"));
|
||||
$sent_count = $row['num'];
|
||||
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('invoice_id') AS num FROM invoices WHERE invoice_status = 'Partial'"));
|
||||
$partial_count = $row['num'];
|
||||
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('invoice_id') AS num FROM invoices WHERE invoice_status = 'Draft'"));
|
||||
$draft_count = $row['num'];
|
||||
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('invoice_id') AS num FROM invoices WHERE invoice_status = 'Cancelled'"));
|
||||
$cancelled_count = $row['num'];
|
||||
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('invoice_id') AS num FROM invoices WHERE invoice_due > CURDATE()"));
|
||||
$overdue_count = $row['num'];
|
||||
|
||||
$sql_total_draft = mysqli_query($mysqli,"SELECT SUM(invoice_amount) AS total_draft FROM invoices WHERE invoice_status = 'Draft'");
|
||||
$row = mysqli_fetch_array($sql_total_draft);
|
||||
$total_draft = $row['total_draft'];
|
||||
|
||||
$sql_total_sent = mysqli_query($mysqli,"SELECT SUM(invoice_amount) AS total_sent FROM invoices WHERE invoice_status = 'Sent'");
|
||||
$row = mysqli_fetch_array($sql_total_sent);
|
||||
$total_sent = $row['total_sent'];
|
||||
|
||||
$sql_total_cancelled = mysqli_query($mysqli,"SELECT SUM(invoice_amount) AS total_cancelled FROM invoices WHERE invoice_status = 'Cancelled'");
|
||||
$row = mysqli_fetch_array($sql_total_cancelled);
|
||||
$total_cancelled = $row['total_cancelled'];
|
||||
|
||||
$sql_total_partial = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS total_partial FROM payments, invoices WHERE payments.invoice_id = invoices.invoice_id AND invoices.invoice_status = 'Partial'");
|
||||
$row = mysqli_fetch_array($sql_total_partial);
|
||||
$total_partial = $row['total_partial'];
|
||||
$total_partial_count = mysqli_num_rows($sql_total_partial);
|
||||
|
||||
$sql_total_overdue_partial = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS total_overdue_partial FROM payments, invoices WHERE payments.invoice_id = invoices.invoice_id AND invoices.invoice_status = 'Partial' AND invoices.invoice_due < CURDATE()");
|
||||
$row = mysqli_fetch_array($sql_total_overdue_partial);
|
||||
$total_overdue_partial = $row['total_overdue_partial'];
|
||||
|
||||
$sql_total_overdue = mysqli_query($mysqli,"SELECT SUM(invoice_amount) AS total_overdue FROM invoices WHERE invoice_status NOT LIKE 'Draft' AND invoice_status NOT LIKE 'Paid' AND invoice_due < CURDATE()");
|
||||
$row = mysqli_fetch_array($sql_total_overdue);
|
||||
$total_overdue = $row['total_overdue'];
|
||||
|
||||
$real_overdue_amount = $total_overdue - $total_overdue_partial;
|
||||
|
||||
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM invoices, clients, categories
|
||||
WHERE invoices.client_id = clients.client_id
|
||||
AND invoices.category_id = categories.category_id
|
||||
ORDER BY invoices.invoice_number DESC");
|
||||
?>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-xl-3 col-sm-6 mb-3">
|
||||
<div class="card text-white bg-secondary o-hidden">
|
||||
<div class="card-body">
|
||||
<div class="card-body-icon">
|
||||
<i class="fas fa-fw fa-pencil-ruler"></i>
|
||||
</div>
|
||||
<div class="mr-5"><?php echo $draft_count; ?> Draft <h1>$<?php echo number_format($total_draft,2); ?></h1></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-xl-3 col-sm-6 mb-3">
|
||||
<div class="card text-white bg-warning o-hidden">
|
||||
<div class="card-body">
|
||||
<div class="card-body-icon">
|
||||
<i class="fas fa-fw fa-paper-plane"></i>
|
||||
</div>
|
||||
<div class="mr-5"><?php echo $sent_count; ?> Sent <h1>$<?php echo number_format($total_sent,2); ?></h1></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-xl-3 col-sm-6 mb-3">
|
||||
<div class="card text-white bg-primary o-hidden">
|
||||
<div class="card-body">
|
||||
<div class="card-body-icon">
|
||||
<i class="fas fa-fw fa-wine-glass-alt"></i>
|
||||
</div>
|
||||
<div class="mr-5"><?php echo $partial_count; ?> Partial <h1>$<?php echo number_format($total_partial,2); ?></h1></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-xl-3 col-sm-6 mb-3">
|
||||
<div class="card text-white bg-danger o-hidden">
|
||||
<div class="card-body">
|
||||
<div class="card-body-icon">
|
||||
<i class="fas fa-fw fa-ban"></i>
|
||||
</div>
|
||||
<div class="mr-5"><?php echo $cancelled_count; ?> Cancelled <h1>$<?php echo number_format($total_cancelled,2); ?></h1></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card mb-3">
|
||||
<div class="card-header">
|
||||
<h6 class="float-left mt-2"><i class="fa fa-fw fa-file mr-2"></i>Invoices</h6>
|
||||
<button type="button" class="btn btn-primary btn-sm float-right" data-toggle="modal" data-target="#addInvoiceModal"><i class="fas fa-fw fa-plus"></i></button>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-borderless table-hover" id="dataTable" width="100%" cellspacing="0">
|
||||
<thead class="thead-dark">
|
||||
<tr>
|
||||
<th>Number</th>
|
||||
<th>Client</th>
|
||||
<th class="text-right">Amount</th>
|
||||
<th>Invoice Date</th>
|
||||
<th>Due Date</th>
|
||||
<th>Category</th>
|
||||
<th>Status</th>
|
||||
<th class="text-center">Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
|
||||
while($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'];
|
||||
$client_id = $row['client_id'];
|
||||
$client_name = $row['client_name'];
|
||||
$category_id = $row['category_id'];
|
||||
$category_name = $row['category_name'];
|
||||
$client_net_terms = $row['client_net_terms'];
|
||||
if($client_net_terms == 0){
|
||||
$client_net_terms = $config_default_net_terms;
|
||||
}
|
||||
|
||||
$now = time();
|
||||
|
||||
if(($invoice_status == "Sent" or $invoice_status == "Partial") and strtotime($invoice_due) < $now ){
|
||||
$overdue_color = "text-danger font-weight-bold";
|
||||
}else{
|
||||
$overdue_color = "";
|
||||
}
|
||||
|
||||
if($invoice_status == "Sent"){
|
||||
$invoice_badge_color = "warning text-white";
|
||||
}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";
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<tr>
|
||||
<td><a href="invoice.php?invoice_id=<?php echo $invoice_id; ?>">INV-<?php echo $invoice_number; ?></a></td>
|
||||
<td><a href="client.php?client_id=<?php echo $client_id; ?>"><?php echo $client_name; ?></a></td>
|
||||
<td class="text-right text-monospace">$<?php echo number_format($invoice_amount,2); ?></td>
|
||||
<td><?php echo $invoice_date; ?></td>
|
||||
<td class="<?php echo $overdue_color; ?>"><?php echo $invoice_due; ?></td>
|
||||
<td><?php echo $category_name; ?></td>
|
||||
<td>
|
||||
<span class="p-2 badge badge-<?php echo $invoice_badge_color; ?>">
|
||||
<?php echo $invoice_status; ?>
|
||||
</span>
|
||||
</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">
|
||||
<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="#editInvoiceModal<?php echo $invoice_id; ?>">Edit</a>
|
||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#addInvoiceCopyModal<?php echo $invoice_id; ?>"><i class="fa fa-fw fa-copy"></i> Copy</a>
|
||||
<a class="dropdown-item" href="post.php?email_invoice=<?php echo $invoice_id; ?>"><i class="fa fa-fw fa-paper-plane"></i> Send</a>
|
||||
<a class="dropdown-item" href="post.php?pdf_invoice=<?php echo $invoice_id; ?>"><i class="fa fa-fw fa-file-pdf"></i> PDF</a>
|
||||
<a class="dropdown-item" href="post.php?delete_invoice=<?php echo $invoice_id; ?>"><i class="fa fa-fw fa-trash"></i> Delete</a>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
include("add_invoice_copy_modal.php");
|
||||
include("edit_invoice_modal.php");
|
||||
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include("add_invoice_modal.php"); ?>
|
||||
|
||||
<?php include("footer.php");
|
||||
37
js/app.js
37
js/app.js
|
|
@ -1,33 +1,11 @@
|
|||
//Prevents resubmit on forms
|
||||
if ( window.history.replaceState ) {
|
||||
window.history.replaceState( null, null, window.location.href );
|
||||
if(window.history.replaceState){
|
||||
window.history.replaceState(null, null, window.location.href);
|
||||
}
|
||||
|
||||
// Call the dataTables jQuery plugin
|
||||
|
||||
$('#dataTable').dataTable( {
|
||||
order: [],
|
||||
language: {
|
||||
search: "_INPUT_",
|
||||
searchPlaceholder: "Search",
|
||||
sLengthMenu: "_MENU_",
|
||||
sInfo: "_START_-_END_ of _TOTAL_",
|
||||
paginate: {
|
||||
previous: '<i class="fa fa-angle-left"></i>',
|
||||
next: '<i class="fa fa-angle-right"></i>'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$(function () {
|
||||
$('#datepicker').datetimepicker({
|
||||
format: 'L'
|
||||
});
|
||||
});
|
||||
|
||||
//Slide alert up after 2 secs
|
||||
$("#alert").fadeTo(2000, 500).slideUp(500, function(){
|
||||
$("#alert").slideUp(500);
|
||||
$("#alert").slideUp(500);
|
||||
});
|
||||
|
||||
new EasyMDE({
|
||||
|
|
@ -36,9 +14,8 @@ new EasyMDE({
|
|||
});
|
||||
|
||||
new EasyMDE({
|
||||
autoDownloadFontAwesome: false,
|
||||
autofocus: true,
|
||||
forceSync: true,
|
||||
element: document.getElementById('editClientNote')
|
||||
|
||||
autoDownloadFontAwesome: false,
|
||||
autofocus: true,
|
||||
forceSync: true,
|
||||
element: document.getElementById('editClientNote')
|
||||
});
|
||||
|
|
@ -34,7 +34,8 @@ if(isset($_POST['login'])){
|
|||
if($client_id > 0){
|
||||
header("Location: client.php?client_id=$client_id");
|
||||
}else{
|
||||
header("Location: $config_start_page");
|
||||
//header("Location: $config_start_page");
|
||||
header("Location: dashboard.php");
|
||||
}
|
||||
|
||||
}else{
|
||||
|
|
@ -42,7 +43,8 @@ if(isset($_POST['login'])){
|
|||
|
||||
if(TokenAuth6238::verify($token,$current_code)){
|
||||
$_SESSION['logged'] = TRUE;
|
||||
header("Location: $config_start_page");
|
||||
//header("Location: $config_start_page");
|
||||
header("Location: dashboard.php");
|
||||
}else{
|
||||
$response = "
|
||||
<div class='alert alert-danger'>
|
||||
|
|
|
|||
|
|
@ -1,114 +0,0 @@
|
|||
<?php include("config.php"); ?>
|
||||
|
||||
<?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 = $_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'];
|
||||
$_SESSION['client_id'] = $row['client_id'];
|
||||
$client_id = $row['client_id'];
|
||||
|
||||
if(empty($token)){
|
||||
$_SESSION['logged'] = TRUE;
|
||||
|
||||
if($client_id > 0){
|
||||
header("Location: client.php?client_id=$client_id");
|
||||
}else{
|
||||
header("Location: $config_start_page");
|
||||
}
|
||||
|
||||
}else{
|
||||
require_once("rfc6238.php");
|
||||
|
||||
if(TokenAuth6238::verify($token,$current_code)){
|
||||
$_SESSION['logged'] = TRUE;
|
||||
header("Location: $config_start_page");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<!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">
|
||||
<meta name="description" content="">
|
||||
<meta name="author" content="">
|
||||
|
||||
<title></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-body bg-white">
|
||||
<form method="post">
|
||||
<div class="form-group">
|
||||
|
||||
<input type="email" name="email" class="form-control" required autofocus>
|
||||
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
||||
<input type="password" name="password" class="form-control" required>
|
||||
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
||||
<input type="text" name="current_code" class="form-control">
|
||||
|
||||
</div>
|
||||
<button class="btn btn-dark btn-block p-4" type="submit" name="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>
|
||||
35
post.php
35
post.php
|
|
@ -297,6 +297,41 @@ if(isset($_POST['edit_user'])){
|
|||
|
||||
}
|
||||
|
||||
if(isset($_POST['add_company'])){
|
||||
|
||||
$name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']));
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO companies SET company_name = '$name', company_created_at = NOW()");
|
||||
|
||||
$_SESSION['alert_message'] = "Company added";
|
||||
|
||||
header("Location: companies.php");
|
||||
|
||||
}
|
||||
|
||||
if(isset($_POST['edit_company'])){
|
||||
$company_id = intval($_POST['company_id']);
|
||||
$name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']));
|
||||
|
||||
mysqli_query($mysqli,"UPDATE companies SET company_name = '$name', company_updated_at = NOW() WHERE company_id = $company_id");
|
||||
|
||||
$_SESSION['alert_message'] = "Company modified";
|
||||
|
||||
header("Location: companies.php");
|
||||
|
||||
}
|
||||
|
||||
if(isset($_GET['delete_company'])){
|
||||
$company_id = intval($_GET['delete_company']);
|
||||
|
||||
mysqli_query($mysqli,"DELETE FROM companies WHERE company_id = $company_id");
|
||||
|
||||
$_SESSION['alert_message'] = "Company deleted";
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
|
||||
}
|
||||
|
||||
if(isset($_POST['add_client'])){
|
||||
|
||||
$name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']));
|
||||
|
|
|
|||
|
|
@ -1,58 +0,0 @@
|
|||
<?php include("header.php"); ?>
|
||||
|
||||
<?php include("settings-nav.php"); ?>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header bg-dark text-white">
|
||||
<h6 class="float-left mt-1"><i class="fa fa-fw fa-address-book mr-2"></i>CardDAV Settings</h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form class="p-3" action="post.php" method="post" autocomplete="off">
|
||||
<div class="form-group">
|
||||
<label>Server</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-server"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="config_smtp_host" placeholder="CardDAV Server Address" value="<?php echo $config_carddav_server; ?>" required autofocus>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Addressbook</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-address-book"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="config_carddav_username" placeholder="Address book name" value="<?php echo $config_carddav_address_book; ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Username</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="config_carddav_username" placeholder="Username" value="<?php echo $config_carddav_username; ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group mb-5">
|
||||
<label>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="config_carddav_password" placeholder="Password" value="<?php echo $config_carddav_password; ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
<button type="submit" name="edit_carddav_settings" class="btn btn-primary">Save</button>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include("footer.php");
|
||||
|
|
@ -110,6 +110,7 @@
|
|||
<a class="dropdown-item" href="settings-general.php">General</a>
|
||||
<a class="dropdown-item" href="categories.php">Categories</a>
|
||||
<a class="dropdown-item" href="users.php">Users</a>
|
||||
<a class="dropdown-item" href="companies.php">Companies</a>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
44
test.php
44
test.php
|
|
@ -1,44 +0,0 @@
|
|||
<?php include("header.php"); ?>
|
||||
|
||||
<!-- Breadcrumbs-->
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item">
|
||||
<a href="index.html">Dashboard</a>
|
||||
</li>
|
||||
<li class="breadcrumb-item active">Blank Page</li>
|
||||
</ol>
|
||||
|
||||
<!-- Page Content -->
|
||||
<h1>PHP SELF basename: <?php echo basename($_SERVER['PHP_SELF']); ?></h1>
|
||||
<h1>PHP SELF: <?php echo $_SERVER['PHP_SELF']; ?></h1>
|
||||
<hr>
|
||||
<h3>PHP URI: <?php echo $_SERVER['REQUEST_URI']; ?></h3>
|
||||
<h3>PHP Server_name: <?php echo $_SERVER['SERVER_NAME']; ?></h3>
|
||||
<h3>PHP HTTP_HOST: <?php echo $_SERVER['HTTP_HOST']; ?></h3>
|
||||
|
||||
<h3><?php echo $_SERVER['HTTP_HOST'] . dirname($_SERVER['REQUEST_URI']); ?></h3>
|
||||
|
||||
<h1>basename _FILE_ : <?php echo basename(__FILE__); ?></h1>
|
||||
<h1>User Agent: <?php echo $_SERVER['HTTP_USER_AGENT']; ?>
|
||||
<p>This is a great starting point for new custom pages.</p>
|
||||
|
||||
<?php
|
||||
require_once('rfc6238.php');
|
||||
|
||||
$secretkey = 'GEZDGNBVGY3TQOJQGEZDGNBVGY3TQOJQ';
|
||||
$currentcode = '739453';
|
||||
if (TokenAuth6238::verify($secretkey,$currentcode)) {
|
||||
echo "Code is valid\n";
|
||||
} else {
|
||||
echo "Invalid code\n";
|
||||
}
|
||||
print sprintf('<img src="%s"/>',TokenAuth6238::getBarCodeUrl('','',$secretkey,'My%20App'));
|
||||
print TokenAuth6238::getTokenCodeDebug($secretkey,0);
|
||||
|
||||
|
||||
?>
|
||||
|
||||
|
||||
<h3><?php echo $config_quote_email_subject; ?></h3>
|
||||
|
||||
<?php include("footer.php"); ?>
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
<?php include("header.php");
|
||||
|
||||
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM transfers");
|
||||
|
||||
?>
|
||||
|
||||
<?php
|
||||
|
||||
while($row = mysqli_fetch_array($sql)){
|
||||
$revenue_id = $row['revenue_id'];
|
||||
|
||||
mysqli_query($mysqli,"UPDATE revenues SET category_id = 0 WHERE revenue_id = $revenue_id");
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<?php include("footer.php");
|
||||
Loading…
Reference in New Issue