mirror of https://github.com/itflow-org/itflow
Refinements to ticketting system, Added force recurring option created company_id chile directories for clients, settings, expenses, added dir checks to add client and add contact and much more.
This commit is contained in:
parent
2984f0ec6c
commit
2e5763dc8d
|
|
@ -2,7 +2,7 @@
|
|||
<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 Contact</h5>
|
||||
<h5 class="modal-title"><i class="far fa-fw fa-address-card mr-2"></i>New Contact</h5>
|
||||
<button type="button" class="close text-white" data-dismiss="modal">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-dollar-sign"></i></span>
|
||||
</div>
|
||||
<input type="number" class="form-control" step="0.01" min="0.00" name="amount" value="<?php echo $balance; ?>" required>
|
||||
<input type="number" class="form-control" step="0.01" min="0" name="amount" value="<?php echo $balance; ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
</div>
|
||||
<div class="form-group">
|
||||
<label>Cost <strong class="text-danger">*</strong></label>
|
||||
<input type="text" class="form-control" name="cost" placeholder="Cost" required>
|
||||
<input type="number" step="0.01" min="0" class="form-control" name="cost" placeholder="Cost" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer bg-white">
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@
|
|||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-bicycle"></i></span>
|
||||
</div>
|
||||
<input type="number" class="form-control" name="miles" value="<?php echo $trip_miles; ?>" required>
|
||||
<input type="number" step="0.1" min="0" class="form-control" name="miles" value="<?php echo $trip_miles; ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -72,6 +72,11 @@
|
|||
<label>Purpose <strong class="text-danger">*</strong></label>
|
||||
<textarea rows="4" class="form-control" name="purpose" required><?php echo $trip_purpose; ?></textarea>
|
||||
</div>
|
||||
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="checkbox" class="custom-control-input" id="customControlAutosizingCopy<?php echo $trip_id; ?>" name="roundtrip" value="1" >
|
||||
<label class="custom-control-label" for="customControlAutosizingCopy<?php echo $trip_id; ?>">Round Trip</label>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@
|
|||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-bicycle"></i></span>
|
||||
</div>
|
||||
<input type="number" class="form-control" name="miles" placeholder="Enter miles" required autofocus>
|
||||
<input type="number" step="0.1" min="0" class="form-control" name="miles" placeholder="Enter miles" required autofocus>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -68,7 +68,7 @@
|
|||
</div>
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="checkbox" class="custom-control-input" id="customControlAutosizing" name="roundtrip" value="1" >
|
||||
<label class="custom-control-label" for="customControlAutosizing">Roundtrip</label>
|
||||
<label class="custom-control-label" for="customControlAutosizing">Round Trip</label>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
|
|||
2
api.php
2
api.php
|
|
@ -20,7 +20,7 @@ if(isset($_GET['api_key'])){
|
|||
$row = mysqli_fetch_array($sql);
|
||||
$name = $row['name'];
|
||||
|
||||
echo $name;
|
||||
echo "$name - $cid";
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,6 +26,9 @@
|
|||
|
||||
include("get_settings.php");
|
||||
|
||||
$_SESSION['alert_message'] = '';
|
||||
$_SESSION['alert_type'] = "warning";
|
||||
|
||||
//Detects if using an apple device and uses apple maps instead of google
|
||||
$iPod = stripos($_SERVER['HTTP_USER_AGENT'],"iPod");
|
||||
$iPhone = stripos($_SERVER['HTTP_USER_AGENT'],"iPhone");
|
||||
|
|
|
|||
|
|
@ -66,9 +66,9 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
|
|||
<table class="table table-striped table-borderless table-hover">
|
||||
<thead class="text-dark">
|
||||
<tr>
|
||||
<th class="w-40"><a class="text-secondary" href="?<?php echo $url_query_strings_sb; ?>&sb=client_name&o=<?php echo $disp; ?>">Name <i class="fa fa-sort<?php if($disp=='ASC'){ echo "-up"; }else{ echo "-down"; }?>"></i></a></th>
|
||||
<th class="w-15"><a href="?<?php echo $url_query_strings_sb; ?>&sb=client_type&o=<?php echo $disp; ?>">Type <i class="fa fa-sort-up"></i></a></th>
|
||||
<th class="w-15"><a class="text-secondary" href="?<?php echo $url_query_strings_sb; ?>&sb=client_email&o=<?php echo $disp; ?>">Email</a></th>
|
||||
<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>
|
||||
|
|
|
|||
|
|
@ -65,6 +65,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="modal-footer bg-white">
|
||||
<a href="post.php?delete_event=<?php echo $event_id; ?>" class="btn btn-outline-danger mr-auto">Delete</a>
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
|
||||
<button type="submit" name="edit_event" class="btn btn-primary">Save</button>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
</div>
|
||||
<div class="form-group">
|
||||
<label>Cost <strong class="text-danger">*</strong></label>
|
||||
<input type="text" class="form-control" name="cost" value="<?php echo $product_cost; ?>" required>
|
||||
<input type="number" step="0.01" min="0" class="form-control" name="cost" value="<?php echo $product_cost; ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer bg-white">
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@
|
|||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-bicycle"></i></span>
|
||||
</div>
|
||||
<input type="number" class="form-control" name="miles" value="<?php echo $trip_miles; ?>" required>
|
||||
<input type="number" step="0.1" min="0" class="form-control" name="miles" value="<?php echo $trip_miles; ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
@ -76,7 +76,7 @@
|
|||
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="checkbox" <?php if($round_trip == 1){ echo "checked"; } ?> class="custom-control-input" id="customControlAutosizing<?php echo $trip_id; ?>" name="roundtrip" value="1" >
|
||||
<label class="custom-control-label" for="customControlAutosizing<?php echo $trip_id; ?>">Roundtrip</label>
|
||||
<label class="custom-control-label" for="customControlAutosizing<?php echo $trip_id; ?>">Round Trip</label>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
|
|
|||
11
footer.php
11
footer.php
|
|
@ -47,3 +47,14 @@
|
|||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
<?php
|
||||
//Debug - Page Load time
|
||||
|
||||
$time = microtime();
|
||||
$time = explode(' ', $time);
|
||||
$time = $time[1] + $time[0];
|
||||
$finish = $time;
|
||||
$total_time = round(($finish - $start), 4);
|
||||
echo 'Page generated in '.$total_time.' seconds.';
|
||||
?>
|
||||
|
|
@ -40,6 +40,9 @@ $config_invoice_overdue_reminders = $row['config_invoice_overdue_reminders'];
|
|||
$config_invoice_next_number = $row['config_invoice_next_number'];
|
||||
$config_invoice_prefix = $row['config_invoice_prefix'];
|
||||
|
||||
$config_ticket_next_number = $row['config_ticket_next_number'];
|
||||
$config_ticket_prefix = $row['config_ticket_prefix'];
|
||||
|
||||
//Defaults
|
||||
$config_default_expense_account = $row['config_default_expense_account'];
|
||||
$config_default_payment_account = $row['config_default_payment_account'];
|
||||
|
|
@ -56,9 +59,6 @@ $config_enable_cron = $row['config_enable_cron'];
|
|||
|
||||
$config_base_url = $row['config_base_url'];
|
||||
|
||||
$_SESSION['alert_message'] = '';
|
||||
$_SESSION['alert_type'] = "warning";
|
||||
|
||||
$client_types_array = array(
|
||||
'Residential',
|
||||
'Law',
|
||||
|
|
|
|||
12
header.php
12
header.php
|
|
@ -1,5 +1,13 @@
|
|||
<?php
|
||||
//Debug - Page Load Time
|
||||
$time = microtime();
|
||||
$time = explode(' ', $time);
|
||||
$time = $time[1] + $time[0];
|
||||
$start = $time;
|
||||
?>
|
||||
|
||||
<?php
|
||||
|
||||
|
||||
if(!file_exists('config.php')){
|
||||
header("Location: setup.php");
|
||||
}
|
||||
|
|
@ -22,7 +30,7 @@
|
|||
<meta name="description" content="">
|
||||
<meta name="author" content="">
|
||||
|
||||
<title><?php echo $config_company_name; ?></title>
|
||||
<title><?php echo $config_app_name; ?></title>
|
||||
|
||||
<link href="vendor/easy-markdown-editor/css/easymde.css" rel="stylesheet" type="text/css">
|
||||
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ if(isset($_GET['invoice_id'])){
|
|||
</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>
|
||||
|
|
@ -225,8 +225,8 @@ if(isset($_GET['invoice_id'])){
|
|||
<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="text" class="form-control" style="text-align: center;" name="qty"></td>
|
||||
<td><input type="text" class="form-control" style="text-align: right;" id="price" name="price"></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>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
<?php include("header.php"); ?>
|
||||
|
||||
<div class="row justify-content-md-center">
|
||||
<div class="col-md-5">
|
||||
<div class="card mt-5">
|
||||
<div class="card-body bg-light text-center">
|
||||
<h2 class="mb-3">Where did everybody go?</h2>
|
||||
<i class="far fa-fw fa-4x fa-frown-open mb-3"></i>
|
||||
<h4 class="mb-4">why not invite someone over?</h4>
|
||||
<button type="button" class="btn btn-primary btn-lg" data-toggle="modal" data-target="#addClientModal"><i class="fas fa-fw fa-plus"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include("add_client_modal.php"); ?>
|
||||
<?php include("footer.php"); ?>
|
||||
237
post.php
237
post.php
|
|
@ -77,6 +77,10 @@ if(isset($_POST['add_company'])){
|
|||
|
||||
$config_api_key = keygen();
|
||||
$company_id = mysqli_insert_id($mysqli);
|
||||
|
||||
mkdir("uploads/clients/$company_id");
|
||||
mkdir("uploads/expenses/$company_id");
|
||||
mkdir("uploads/settings/$company_id");
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO settings SET company_id = $company_id, config_company_name = '$name', config_invoice_prefix = 'INV-', config_invoice_next_number = 1, config_invoice_overdue_reminders = '1,3,7', config_quote_prefix = 'QUO-', config_quote_next_number = 1, config_api_key = '$config_api_key', config_recurring_auto_send_invoice = 1, config_default_net_terms = 7, config_send_invoice_reminders = 0, config_enable_cron = 0");
|
||||
|
||||
|
|
@ -133,19 +137,13 @@ if(isset($_POST['edit_general_settings'])){
|
|||
$config_api_key = strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_api_key']));
|
||||
$config_enable_cron = intval($_POST['config_enable_cron']);
|
||||
|
||||
if($config_enable_cron == 1){
|
||||
$config_enable_cron = 1;
|
||||
}else{
|
||||
$config_enable_cron = 0;
|
||||
}
|
||||
|
||||
$path = "$config_invoice_logo";
|
||||
|
||||
if($_FILES['file']['tmp_name']!='') {
|
||||
//delete old avatar file
|
||||
unlink($path);
|
||||
//Update with new path
|
||||
$path = "uploads/settings/";
|
||||
$path = "uploads/settings/$session_company_id/";
|
||||
$path = $path . basename( $_FILES['file']['name']);
|
||||
$file_name = basename($path);
|
||||
move_uploaded_file($_FILES['file']['tmp_name'], $path);
|
||||
|
|
@ -168,8 +166,6 @@ if(isset($_POST['edit_company_settings'])){
|
|||
$config_company_zip = strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_company_zip']));
|
||||
$config_company_phone = strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_company_phone']));
|
||||
$config_company_site = strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_company_site']));
|
||||
|
||||
|
||||
|
||||
mysqli_query($mysqli,"UPDATE settings SET config_company_name = '$config_company_name', config_company_address = '$config_company_address', config_company_city = '$config_company_city', config_company_state = '$config_company_state', config_company_zip = '$config_company_zip', config_company_phone = '$config_company_phone', config_company_site = '$config_company_site' WHERE company_id = $session_company_id");
|
||||
|
||||
|
|
@ -184,7 +180,7 @@ if(isset($_POST['edit_mail_settings'])){
|
|||
$config_smtp_host = strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_smtp_host']));
|
||||
$config_smtp_port = intval($_POST['config_smtp_port']);
|
||||
$config_smtp_username = strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_smtp_username']));
|
||||
$config_smtp_password = strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_smtp_password']));
|
||||
$config_smtp_password = mysqli_real_escape_string($mysqli,$_POST['config_smtp_password']);
|
||||
|
||||
mysqli_query($mysqli,"UPDATE settings SET config_smtp_host = '$config_smtp_host', config_smtp_port = $config_smtp_port, config_smtp_username = '$config_smtp_username', config_smtp_password = '$config_smtp_password' WHERE company_id = $session_company_id");
|
||||
|
||||
|
|
@ -201,12 +197,7 @@ if(isset($_POST['edit_invoice_settings'])){
|
|||
$config_mail_from_email = strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_mail_from_email']));
|
||||
$config_mail_from_name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_mail_from_name']));
|
||||
$config_invoice_footer = strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_invoice_footer']));
|
||||
$config_send_invoice_reminders = $_POST['config_send_invoice_reminders'];
|
||||
if($config_send_invoice_reminders == 1){
|
||||
$config_send_invoice_reminders = 1;
|
||||
}else{
|
||||
$config_send_invoice_reminders = 0;
|
||||
}
|
||||
$config_send_invoice_reminders = intval($_POST['config_send_invoice_reminders']);
|
||||
$config_invoice_overdue_reminders = strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_invoice_overdue_reminders']));
|
||||
|
||||
mysqli_query($mysqli,"UPDATE settings SET config_invoice_prefix = '$config_invoice_prefix', config_invoice_next_number = $config_invoice_next_number, config_mail_from_email = '$config_mail_from_email', config_mail_from_name = '$config_mail_from_name', config_invoice_footer = '$config_invoice_footer', config_send_invoice_reminders = $config_send_invoice_reminders, config_invoice_overdue_reminders = '$config_invoice_overdue_reminders' WHERE company_id = $session_company_id");
|
||||
|
|
@ -231,6 +222,18 @@ if(isset($_POST['edit_quote_settings'])){
|
|||
|
||||
}
|
||||
|
||||
if(isset($_POST['edit_ticket_settings'])){
|
||||
|
||||
$config_ticket_prefix = strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_ticket_prefix']));
|
||||
$config_ticket_next_number = intval($_POST['config_ticket_next_number']);
|
||||
|
||||
mysqli_query($mysqli,"UPDATE settings SET config_ticket_prefix = '$config_ticket_prefix', config_ticket_next_number = $config_ticket_next_number WHERE company_id = $session_company_id");
|
||||
|
||||
$_SESSION['alert_message'] = "Ticket Settings updated";
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
|
||||
}
|
||||
|
||||
if(isset($_POST['edit_default_settings'])){
|
||||
|
||||
|
|
@ -365,7 +368,7 @@ if(isset($_POST['add_client'])){
|
|||
$client_id = mysqli_insert_id($mysqli);
|
||||
|
||||
//Should be created when files are uploaded
|
||||
//mkdir("uploads/clients/$client_id");
|
||||
mkdir("uploads/clients/$session_company_id/$client_id");
|
||||
|
||||
$_SESSION['alert_message'] = "Client added";
|
||||
|
||||
|
|
@ -452,7 +455,7 @@ if(isset($_POST['edit_event'])){
|
|||
}
|
||||
|
||||
if(isset($_GET['delete_event'])){
|
||||
$event_id = intval($_GET['delete_calendar_event']);
|
||||
$event_id = intval($_GET['delete_event']);
|
||||
|
||||
mysqli_query($mysqli,"DELETE FROM events WHERE event_id = $event_id");
|
||||
|
||||
|
|
@ -468,7 +471,12 @@ if(isset($_POST['add_ticket'])){
|
|||
$subject = strip_tags(mysqli_real_escape_string($mysqli,$_POST['subject']));
|
||||
$details = strip_tags(mysqli_real_escape_string($mysqli,$_POST['details']));
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO tickets SET ticket_subject = '$subject', ticket_details = '$details', ticket_status = 'Open', ticket_created_at = NOW(), client_id = $client_id, company_id = $session_company_id");
|
||||
//Get the next Ticket Number and add 1 for the new ticket number
|
||||
$ticket_number = $config_ticket_next_number;
|
||||
$new_config_ticket_next_number = $config_ticket_next_number + 1;
|
||||
mysqli_query($mysqli,"UPDATE settings SET config_ticket_next_number = $new_config_ticket_next_number WHERE company_id = $session_company_id");
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO tickets SET ticket_number = $ticket_number, ticket_subject = '$subject', ticket_details = '$details', ticket_status = 'Open', ticket_created_at = NOW(), ticket_created_by = $session_user_id, client_id = $client_id, company_id = $session_company_id");
|
||||
|
||||
$_SESSION['alert_message'] = "Ticket created";
|
||||
|
||||
|
|
@ -501,6 +509,19 @@ if(isset($_GET['delete_ticket'])){
|
|||
|
||||
}
|
||||
|
||||
if(isset($_POST['add_ticket_update'])){
|
||||
|
||||
$ticket_id = intval($_POST['ticket_id']);
|
||||
$ticket_update = strip_tags(mysqli_real_escape_string($mysqli,$_POST['ticket_update']));
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO ticket_updates SET ticket_update = '$ticket_update', ticket_update_created_at = NOW(), user_id = $session_user_id, ticket_id = $ticket_id, company_id = $session_company_id") or die(mysqli_error($mysqli));
|
||||
|
||||
$_SESSION['alert_message'] = "Posted an update";
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
|
||||
}
|
||||
|
||||
if(isset($_POST['add_vendor'])){
|
||||
|
||||
$client_id = intval($_POST['client_id']); //Used if this vendor is under a contact otherwise its 0 for under company
|
||||
|
|
@ -566,7 +587,7 @@ if(isset($_POST['add_product'])){
|
|||
|
||||
$name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']));
|
||||
$description = strip_tags(mysqli_real_escape_string($mysqli,$_POST['description']));
|
||||
$cost = strip_tags(mysqli_real_escape_string($mysqli,$_POST['cost']));
|
||||
$cost = floatval($_POST['cost']);
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO products SET product_name = '$name', product_description = '$description', product_cost = '$cost', product_created_at = NOW(), company_id = $session_company_id");
|
||||
|
||||
|
|
@ -581,7 +602,7 @@ if(isset($_POST['edit_product'])){
|
|||
$product_id = intval($_POST['product_id']);
|
||||
$name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']));
|
||||
$description = strip_tags(mysqli_real_escape_string($mysqli,$_POST['description']));
|
||||
$cost = strip_tags(mysqli_real_escape_string($mysqli,$_POST['cost']));
|
||||
$cost = floatval($_POST['cost']);
|
||||
|
||||
mysqli_query($mysqli,"UPDATE products SET product_name = '$name', product_description = '$description', product_cost = '$cost', product_updated_at = NOW() WHERE product_id = $product_id");
|
||||
|
||||
|
|
@ -607,7 +628,7 @@ if(isset($_POST['add_trip'])){
|
|||
$date = strip_tags(mysqli_real_escape_string($mysqli,$_POST['date']));
|
||||
$starting_location = strip_tags(mysqli_real_escape_string($mysqli,$_POST['starting_location']));
|
||||
$destination = strip_tags(mysqli_real_escape_string($mysqli,$_POST['destination']));
|
||||
$miles = intval($_POST['miles']);
|
||||
$miles = floatval($_POST['miles']);
|
||||
$roundtrip = intval($_POST['roundtrip']);
|
||||
$purpose = strip_tags(mysqli_real_escape_string($mysqli,$_POST['purpose']));
|
||||
$client_id = intval($_POST['client']);
|
||||
|
|
@ -615,7 +636,7 @@ if(isset($_POST['add_trip'])){
|
|||
$location_id = intval($_POST['location']);
|
||||
$vendor_id = intval($_POST['vendor']);
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO trips SET trip_date = '$date', trip_starting_location = '$starting_location', trip_destination = '$destination', trip_miles = $miles, round_trip = $round_trip, trip_purpose = '$purpose', trip_created_at = NOW(), client_id = $client_id, invoice_id = $invoice_id, location_id = $location_id, vendor_id = $vendor_id, company_id = $session_company_id");
|
||||
mysqli_query($mysqli,"INSERT INTO trips SET trip_date = '$date', trip_starting_location = '$starting_location', trip_destination = '$destination', trip_miles = $miles, round_trip = $roundtrip, trip_purpose = '$purpose', trip_created_at = NOW(), client_id = $client_id, invoice_id = $invoice_id, location_id = $location_id, vendor_id = $vendor_id, company_id = $session_company_id");
|
||||
|
||||
$_SESSION['alert_message'] = "Trip added";
|
||||
|
||||
|
|
@ -629,7 +650,7 @@ if(isset($_POST['edit_trip'])){
|
|||
$date = strip_tags(mysqli_real_escape_string($mysqli,$_POST['date']));
|
||||
$starting_location = strip_tags(mysqli_real_escape_string($mysqli,$_POST['starting_location']));
|
||||
$destination = strip_tags(mysqli_real_escape_string($mysqli,$_POST['destination']));
|
||||
$miles = intval($_POST['miles']);
|
||||
$miles = floatval($_POST['miles']);
|
||||
$roundtrip = intval($_POST['roundtrip']);
|
||||
$purpose = strip_tags(mysqli_real_escape_string($mysqli,$_POST['purpose']));
|
||||
$client_id = intval($_POST['client']);
|
||||
|
|
@ -637,7 +658,7 @@ if(isset($_POST['edit_trip'])){
|
|||
$location_id = intval($_POST['location']);
|
||||
$vendor_id = intval($_POST['vendor']);
|
||||
|
||||
mysqli_query($mysqli,"UPDATE trips SET trip_date = '$date', trip_starting_location = '$starting_location', trip_destination = '$destination', trip_miles = $miles, trip_purpose = '$purpose', round_trip = $round_trip, trip_updated_at = NOW(), client_id = $client_id, invoice_id = $invoice_id, location_id = $location_id, vendor_id = $vendor_id WHERE trip_id = $trip_id");
|
||||
mysqli_query($mysqli,"UPDATE trips SET trip_date = '$date', trip_starting_location = '$starting_location', trip_destination = '$destination', trip_miles = $miles, trip_purpose = '$purpose', round_trip = $roundtrip, trip_updated_at = NOW(), client_id = $client_id, invoice_id = $invoice_id, location_id = $location_id, vendor_id = $vendor_id WHERE trip_id = $trip_id");
|
||||
|
||||
$_SESSION['alert_message'] = "Trip modified";
|
||||
|
||||
|
|
@ -767,7 +788,7 @@ if(isset($_GET['ack_all_alerts'])){
|
|||
if(isset($_POST['add_expense'])){
|
||||
|
||||
$date = strip_tags(mysqli_real_escape_string($mysqli,$_POST['date']));
|
||||
$amount = $_POST['amount'];
|
||||
$amount = floatval($_POST['amount']);
|
||||
$account = intval($_POST['account']);
|
||||
$vendor = intval($_POST['vendor']);
|
||||
$category = intval($_POST['category']);
|
||||
|
|
@ -775,7 +796,7 @@ if(isset($_POST['add_expense'])){
|
|||
$reference = strip_tags(mysqli_real_escape_string($mysqli,$_POST['reference']));
|
||||
|
||||
if($_FILES['file']['tmp_name']!='') {
|
||||
$path = "uploads/expenses/";
|
||||
$path = "uploads/expenses/$session_company_id/";
|
||||
$path = $path . basename( $_FILES['file']['name']);
|
||||
$file_name = basename($path);
|
||||
move_uploaded_file($_FILES['file']['tmp_name'], $path);
|
||||
|
|
@ -793,7 +814,7 @@ if(isset($_POST['edit_expense'])){
|
|||
|
||||
$expense_id = intval($_POST['expense_id']);
|
||||
$date = strip_tags(mysqli_real_escape_string($mysqli,$_POST['date']));
|
||||
$amount = $_POST['amount'];
|
||||
$amount = floatval($_POST['amount']);
|
||||
$account = intval($_POST['account']);
|
||||
$vendor = intval($_POST['vendor']);
|
||||
$category = intval($_POST['category']);
|
||||
|
|
@ -804,7 +825,7 @@ if(isset($_POST['edit_expense'])){
|
|||
if($_FILES['file']['tmp_name']!='') {
|
||||
//remove old receipt
|
||||
unlink($path);
|
||||
$path = "uploads/expenses/";
|
||||
$path = "uploads/expenses/$session_company_id/";
|
||||
$path = $path . basename( $_FILES['file']['name']);
|
||||
$file_name = basename($path);
|
||||
move_uploaded_file($_FILES['file']['tmp_name'], $path);
|
||||
|
|
@ -838,7 +859,7 @@ if(isset($_GET['delete_expense'])){
|
|||
if(isset($_POST['add_transfer'])){
|
||||
|
||||
$date = strip_tags(mysqli_real_escape_string($mysqli,$_POST['date']));
|
||||
$amount = $_POST['amount'];
|
||||
$amount = floatval($_POST['amount']);
|
||||
$account_from = intval($_POST['account_from']);
|
||||
$account_to = intval($_POST['account_to']);
|
||||
|
||||
|
|
@ -862,7 +883,7 @@ if(isset($_POST['edit_transfer'])){
|
|||
$expense_id = intval($_POST['expense_id']);
|
||||
$revenue_id = intval($_POST['revenue_id']);
|
||||
$date = strip_tags(mysqli_real_escape_string($mysqli,$_POST['date']));
|
||||
$amount = $_POST['amount'];
|
||||
$amount = floatval($_POST['amount']);
|
||||
$account_from = intval($_POST['account_from']);
|
||||
$account_to = intval($_POST['account_to']);
|
||||
|
||||
|
|
@ -962,11 +983,11 @@ if(isset($_POST['add_invoice_copy'])){
|
|||
$client_id = $row['client_id'];
|
||||
$category_id = $row['category_id'];
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO invoices SET invoice_number = '$invoice_number', invoice_date = '$date', invoice_due = DATE_ADD('$date', INTERVAL $client_net_terms day), category_id = $category_id, invoice_status = 'Draft', invoice_amount = '$invoice_amount', invoice_note = '$invoice_note', invoice_created_at = NOW(), client_id = $client_id, company_id = $session_company_id");
|
||||
mysqli_query($mysqli,"INSERT INTO invoices SET invoice_number = '$invoice_number', invoice_date = '$date', invoice_due = DATE_ADD('$date', INTERVAL $client_net_terms day), category_id = $category_id, invoice_status = 'Draft', invoice_amount = '$invoice_amount', invoice_note = '$invoice_note', invoice_created_at = NOW(), client_id = $client_id, company_id = $session_company_id") or die(mysql_error());
|
||||
|
||||
$new_invoice_id = mysqli_insert_id($mysqli);
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = 'Draft', history_description = 'INVOICE added!', invoice_id = $new_invoice_id, company_id = $session_company_id");
|
||||
mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = 'Draft', history_description = 'Copied INVOICE!', history_created_at = NOW(), invoice_id = $new_invoice_id, company_id = $session_company_id");
|
||||
|
||||
$sql_items = mysqli_query($mysqli,"SELECT * FROM invoice_items WHERE invoice_id = $invoice_id");
|
||||
while($row = mysqli_fetch_array($sql_items)){
|
||||
|
|
@ -1005,6 +1026,8 @@ if(isset($_POST['add_invoice_recurring'])){
|
|||
|
||||
$recurring_id = mysqli_insert_id($mysqli);
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = 'Draft', history_description = 'Recurring Created from INVOICE!', history_created_at = NOW(), recurring_id = $recurring_id, company_id = $session_company_id");
|
||||
|
||||
$sql_items = mysqli_query($mysqli,"SELECT * FROM invoice_items WHERE invoice_id = $invoice_id");
|
||||
while($row = mysqli_fetch_array($sql_items)){
|
||||
$item_id = $row['item_id'];
|
||||
|
|
@ -1145,9 +1168,9 @@ if(isset($_POST['save_quote'])){
|
|||
if(isset($_POST['name'])){
|
||||
$name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name']));
|
||||
$description = strip_tags(mysqli_real_escape_string($mysqli,$_POST['description']));
|
||||
$qty = $_POST['qty'];
|
||||
$price = $_POST['price'];
|
||||
$tax = $_POST['tax'];
|
||||
$qty = floatval($_POST['qty']);
|
||||
$price = floatval($_POST['price']);
|
||||
$tax = floatval($_POST['tax']);
|
||||
|
||||
$subtotal = $price * $qty;
|
||||
$tax = $subtotal * $tax;
|
||||
|
|
@ -1798,9 +1821,9 @@ if(isset($_GET['delete_invoice_item'])){
|
|||
if(isset($_POST['add_payment'])){
|
||||
|
||||
$invoice_id = intval($_POST['invoice_id']);
|
||||
$balance = $_POST['balance'];
|
||||
$balance = floatval($_POST['balance']);
|
||||
$date = strip_tags(mysqli_real_escape_string($mysqli,$_POST['date']));
|
||||
$amount = $_POST['amount'];
|
||||
$amount = floatval($_POST['amount']);
|
||||
$account = intval($_POST['account']);
|
||||
$payment_method = strip_tags(mysqli_real_escape_string($mysqli,$_POST['payment_method']));
|
||||
$reference = strip_tags(mysqli_real_escape_string($mysqli,$_POST['reference']));
|
||||
|
|
@ -2312,8 +2335,12 @@ if(isset($_POST['add_contact'])){
|
|||
$mobile = preg_replace("/[^0-9]/", '',$mobile);
|
||||
$email = strip_tags(mysqli_real_escape_string($mysqli,$_POST['email']));
|
||||
|
||||
if(!file_exists("uploads/clients/$session_company_id/$client_id")) {
|
||||
mkdir("uploads/clients/$session_company_id/$client_id");
|
||||
}
|
||||
|
||||
if($_FILES['file']['tmp_name']!='') {
|
||||
$path = "uploads/clients/$client_id/";
|
||||
$path = "uploads/clients/$session_company_id/$client_id/";
|
||||
$path = $path . time() . basename( $_FILES['file']['name']);
|
||||
$file_name = basename($path);
|
||||
move_uploaded_file($_FILES['file']['tmp_name'], $path);
|
||||
|
|
@ -2341,8 +2368,12 @@ if(isset($_POST['edit_contact'])){
|
|||
|
||||
$path = strip_tags(mysqli_real_escape_string($mysqli,$_POST['current_avatar_path']));
|
||||
|
||||
if(!file_exists("uploads/clients/$session_company_id/$client_id")) {
|
||||
mkdir("uploads/clients/$session_company_id/$client_id");
|
||||
}
|
||||
|
||||
if($_FILES['file']['tmp_name']!='') {
|
||||
$path = "uploads/clients/$client_id/";
|
||||
$path = "uploads/clients/$session_company_id/$client_id/";
|
||||
$path = $path . time() . basename( $_FILES['file']['name']);
|
||||
$file_name = basename($path);
|
||||
move_uploaded_file($_FILES['file']['tmp_name'], $path);
|
||||
|
|
@ -2571,8 +2602,12 @@ if(isset($_POST['add_file'])){
|
|||
$client_id = intval($_POST['client_id']);
|
||||
$new_name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['new_name']));
|
||||
|
||||
if(!file_exists("uploads/clients/$session_company_id/$client_id")) {
|
||||
mkdir("uploads/clients/$session_company_id/$client_id");
|
||||
}
|
||||
|
||||
if($_FILES['file']['tmp_name']!='') {
|
||||
$path = "uploads/clients/$client_id/";
|
||||
$path = "uploads/clients/$session_company_id/$client_id/";
|
||||
$path = $path . basename( $_FILES['file']['name']);
|
||||
$file_name = basename($path);
|
||||
move_uploaded_file($_FILES['file']['tmp_name'], $path);
|
||||
|
|
@ -2804,4 +2839,124 @@ if(isset($_GET['delete_software'])){
|
|||
|
||||
}
|
||||
|
||||
if(isset($_GET['force_recurring'])){
|
||||
$recurring_id = intval($_GET['force_recurring']);
|
||||
|
||||
$sql_recurring = mysqli_query($mysqli,"SELECT * FROM recurring, clients WHERE clients.client_id = recurring.client_id AND recurring.recurring_id = $recurring_id");
|
||||
|
||||
$row = mysqli_fetch_array($sql_recurring);
|
||||
$recurring_id = $row['recurring_id'];
|
||||
$recurring_frequency = $row['recurring_frequency'];
|
||||
$recurring_status = $row['recurring_status'];
|
||||
$recurring_last_sent = $row['recurring_last_sent'];
|
||||
$recurring_next_date = $row['recurring_next_date'];
|
||||
$recurring_amount = $row['recurring_amount'];
|
||||
$recurring_note = $row['recurring_note'];
|
||||
$category_id = $row['category_id'];
|
||||
$client_id = $row['client_id'];
|
||||
$client_name = $row['client_name'];
|
||||
$client_net_terms = $row['client_net_terms'];
|
||||
|
||||
//Get the last Invoice Number and add 1 for the new invoice number
|
||||
$new_invoice_number = "$config_invoice_prefix$config_invoice_next_number";
|
||||
$new_config_invoice_next_number = $config_invoice_next_number + 1;
|
||||
mysqli_query($mysqli,"UPDATE settings SET config_invoice_next_number = $new_config_invoice_next_number WHERE company_id = $session_company_id");
|
||||
|
||||
//Generate a unique URL key for clients to access
|
||||
$url_key = keygen();
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO invoices SET invoice_number = '$new_invoice_number', invoice_date = CURDATE(), invoice_due = DATE_ADD(CURDATE(), INTERVAL $client_net_terms day), invoice_amount = '$recurring_amount', invoice_note = '$recurring_note', category_id = $category_id, invoice_status = 'Sent', invoice_url_key = '$url_key', invoice_created_at = NOW(), client_id = $client_id, company_id = $session_company_id");
|
||||
|
||||
$new_invoice_id = mysqli_insert_id($mysqli);
|
||||
|
||||
//Copy Items from original invoice to new invoice
|
||||
$sql_invoice_items = mysqli_query($mysqli,"SELECT * FROM invoice_items WHERE recurring_id = $recurring_id ORDER BY item_id ASC");
|
||||
|
||||
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'];
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO invoice_items SET item_name = '$item_name', item_description = '$item_description', item_quantity = $item_quantity, item_price = '$item_price', item_subtotal = '$item_subtotal', item_tax = '$item_tax', item_total = '$item_total', item_created_at = NOW(), invoice_id = $new_invoice_id, company_id = $session_company_id");
|
||||
}
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = 'Sent', history_description = 'Invoice Generated from Recurring!', history_created_at = NOW(), invoice_id = $new_invoice_id, company_id = $session_company_id");
|
||||
|
||||
//update the recurring invoice with the new dates
|
||||
mysqli_query($mysqli,"UPDATE recurring SET recurring_last_sent = CURDATE(), recurring_next_date = DATE_ADD(CURDATE(), INTERVAL 1 $recurring_frequency), recurring_updated_at = NOW() WHERE recurring_id = $recurring_id");
|
||||
|
||||
if($config_recurring_email_auto_send == 1){
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM invoices, clients
|
||||
WHERE invoices.client_id = clients.client_id
|
||||
AND invoices.invoice_id = $new_invoice_id"
|
||||
);
|
||||
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$invoice_number = $row['invoice_number'];
|
||||
$invoice_date = $row['invoice_date'];
|
||||
$invoice_due = $row['invoice_due'];
|
||||
$invoice_amount = $row['invoice_amount'];
|
||||
$invoice_url_key = $row['invoice_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);
|
||||
}
|
||||
$base_url = $_SERVER['HTTP_HOST'] . dirname($_SERVER['REQUEST_URI']);
|
||||
|
||||
$mail = new PHPMailer(true);
|
||||
|
||||
try{
|
||||
|
||||
//Mail Server Settings
|
||||
|
||||
//$mail->SMTPDebug = 2; // Enable verbose debug output
|
||||
$mail->isSMTP(); // Set mailer to use SMTP
|
||||
$mail->Host = $config_smtp_host; // Specify main and backup SMTP servers
|
||||
$mail->SMTPAuth = true; // Enable SMTP authentication
|
||||
$mail->Username = $config_smtp_username; // SMTP username
|
||||
$mail->Password = $config_smtp_password; // SMTP password
|
||||
$mail->SMTPSecure = 'tls'; // Enable TLS encryption, `ssl` also accepted
|
||||
$mail->Port = $config_smtp_port; // TCP port to connect to
|
||||
|
||||
//Recipients
|
||||
$mail->setFrom($config_mail_from_email, $config_mail_from_name);
|
||||
$mail->addAddress("$client_email", "$client_name"); // Add a recipient
|
||||
|
||||
// Content
|
||||
$mail->isHTML(true); // Set email format to HTML
|
||||
|
||||
$mail->Subject = "Invoice $invoice_number";
|
||||
$mail->Body = "Hello $client_name,<br><br>Please view the details of the invoice below.<br><br>Invoice: $invoice_number<br>Issue Date: $invoice_date<br>Total: $$invoice_amount<br>Due Date: $invoice_due<br><br><br>To view your invoice online click <a href='https://$config_base_url/guest_view_invoice.php?invoice_id=$new_invoice_id&url_key=$invoice_url_key'>here</a><br><br><br>~<br>$company_name<br>$config_company_phone";
|
||||
|
||||
$mail->send();
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = 'Sent', history_description = 'Auto Emailed Invoice!', history_created_at = NOW(), invoice_id = $new_invoice_id, company_id = $session_company_id");
|
||||
|
||||
//Update Invoice Status to Sent
|
||||
mysqli_query($mysqli,"UPDATE invoices SET invoice_status = 'Sent', invoice_updated_at = NOW(), client_id = $client_id WHERE invoice_id = $new_invoice_id");
|
||||
|
||||
}catch(Exception $e){
|
||||
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
|
||||
mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = 'Draft', history_description = 'Failed to send Invoice!', history_created_at = NOW(), invoice_id = $new_invoice_id, company_id = $session_company_id");
|
||||
} //End Mail Try
|
||||
} //End Recurring Invoices Loop
|
||||
|
||||
$_SESSION['alert_message'] = "Recurring Invoice Forced";
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
|
||||
} //End Force Recurring
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,377 @@
|
|||
<?php include("header.php"); ?>
|
||||
|
||||
<?php
|
||||
|
||||
if(isset($_GET['year'])){
|
||||
$year = intval($_GET['year']);
|
||||
}else{
|
||||
$year = date('Y');
|
||||
}
|
||||
|
||||
$sql_categories_income = mysqli_query($mysqli,"SELECT * FROM categories WHERE category_type = 'Income' AND company_id = $session_company_id ORDER BY category_name ASC");
|
||||
|
||||
$sql_categories_expense = mysqli_query($mysqli,"SELECT * FROM categories WHERE category_type = 'Expense' AND company_id = $session_company_id ORDER BY category_name ASC");
|
||||
|
||||
|
||||
?>
|
||||
|
||||
<h3 class="text-center mb-3">Profit & Loss <?php echo $year; ?> <?php echo $config_company_name; ?></h3>
|
||||
<table class="table table-sm">
|
||||
<thead>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th class="text-right">Jan-Mar</th>
|
||||
<th class="text-right">Apr-Jun</th>
|
||||
<th class="text-right">Jul-Sep</th>
|
||||
<th class="text-right">Oct-Dec</th>
|
||||
<th class="text-right">Total</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><br><br>Income</th>
|
||||
<th colspan="5"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
while($row = mysqli_fetch_array($sql_categories_income)){
|
||||
$category_id = $row['category_id'];
|
||||
$category_name = $row['category_name'];
|
||||
?>
|
||||
|
||||
<tr>
|
||||
<td><?php echo $category_name; ?></td>
|
||||
|
||||
<?php
|
||||
|
||||
for($month = 1; $month<=3; $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 invoices.category_id = $category_id AND YEAR(payment_date) = $year AND MONTH(payment_date) = $month");
|
||||
$row = mysqli_fetch_array($sql_payments);
|
||||
$payment_amount_for_month = $row['payment_amount_for_month'];
|
||||
|
||||
$sql_revenues = mysqli_query($mysqli,"SELECT SUM(revenue_amount) AS revenue_amount_for_month FROM revenues WHERE revenues.category_id = $category_id AND YEAR(revenue_date) = $year AND MONTH(revenue_date) = $month");
|
||||
$row = mysqli_fetch_array($sql_revenues);
|
||||
$revenue_amount_for_month = $row['revenue_amount_for_month'];
|
||||
|
||||
$payment_amount_for_month = $payment_amount_for_month + $revenue_amount_for_month;
|
||||
|
||||
$payment_amount_for_quarter_one = $payment_amount_for_quarter_one + $payment_amount_for_month;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<td class="text-right text-monospace">$<?php echo number_format($payment_amount_for_quarter_one,2); ?></td>
|
||||
|
||||
<?php
|
||||
|
||||
for($month = 4; $month<=6; $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 invoices.category_id = $category_id AND YEAR(payment_date) = $year AND MONTH(payment_date) = $month");
|
||||
$row = mysqli_fetch_array($sql_payments);
|
||||
$payment_amount_for_month = $row['payment_amount_for_month'];
|
||||
|
||||
$sql_revenues = mysqli_query($mysqli,"SELECT SUM(revenue_amount) AS revenue_amount_for_month FROM revenues WHERE revenues.category_id = $category_id AND YEAR(revenue_date) = $year AND MONTH(revenue_date) = $month");
|
||||
$row = mysqli_fetch_array($sql_revenues);
|
||||
$revenue_amount_for_month = $row['revenue_amount_for_month'];
|
||||
|
||||
$payment_amount_for_month = $payment_amount_for_month + $revenue_amount_for_month;
|
||||
|
||||
$payment_amount_for_quarter_two = $payment_amount_for_quarter_two + $payment_amount_for_month;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<td class="text-right text-monospace">$<?php echo number_format($payment_amount_for_quarter_two,2); ?></td>
|
||||
|
||||
<?php
|
||||
|
||||
for($month = 7; $month<=9; $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 invoices.category_id = $category_id AND YEAR(payment_date) = $year AND MONTH(payment_date) = $month");
|
||||
$row = mysqli_fetch_array($sql_payments);
|
||||
$payment_amount_for_month = $row['payment_amount_for_month'];
|
||||
|
||||
$sql_revenues = mysqli_query($mysqli,"SELECT SUM(revenue_amount) AS revenue_amount_for_month FROM revenues WHERE revenues.category_id = $category_id AND YEAR(revenue_date) = $year AND MONTH(revenue_date) = $month");
|
||||
$row = mysqli_fetch_array($sql_revenues);
|
||||
$revenue_amount_for_month = $row['revenue_amount_for_month'];
|
||||
|
||||
$payment_amount_for_month = $payment_amount_for_month + $revenue_amount_for_month;
|
||||
$payment_amount_for_quarter_three = $payment_amount_for_quarter_three + $payment_amount_for_month;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<td class="text-right text-monospace">$<?php echo number_format($payment_amount_for_quarter_three,2); ?></td>
|
||||
|
||||
<?php
|
||||
|
||||
for($month = 10; $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 invoices.category_id = $category_id AND YEAR(payment_date) = $year AND MONTH(payment_date) = $month");
|
||||
$row = mysqli_fetch_array($sql_payments);
|
||||
$payment_amount_for_month = $row['payment_amount_for_month'];
|
||||
|
||||
$sql_revenues = mysqli_query($mysqli,"SELECT SUM(revenue_amount) AS revenue_amount_for_month FROM revenues WHERE revenues.category_id = $category_id AND YEAR(revenue_date) = $year AND MONTH(revenue_date) = $month");
|
||||
$row = mysqli_fetch_array($sql_revenues);
|
||||
$revenue_amount_for_month = $row['revenue_amount_for_month'];
|
||||
|
||||
$payment_amount_for_month = $payment_amount_for_month + $revenue_amount_for_month;
|
||||
$payment_amount_for_quarter_four = $payment_amount_for_quarter_four + $payment_amount_for_month;
|
||||
}
|
||||
|
||||
$total_payments_for_all_four_quarters = $payment_amount_for_quarter_one + $payment_amount_for_quarter_two + $payment_amount_for_quarter_three + $payment_amount_for_quarter_four;
|
||||
|
||||
?>
|
||||
|
||||
<td class="text-right text-monospace">$<?php echo number_format($payment_amount_for_quarter_four,2); ?></td>
|
||||
|
||||
<td class="text-right text-monospace">$<?php echo number_format($total_payments_for_all_four_quarters,2); ?></td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
|
||||
$payment_amount_for_quarter_one = 0;
|
||||
$payment_amount_for_quarter_two = 0;
|
||||
$payment_amount_for_quarter_three = 0;
|
||||
$payment_amount_for_quarter_four = 0;
|
||||
$total_payment_for_all_months = 0;
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<tr>
|
||||
<th>Gross Profit</th>
|
||||
<?php
|
||||
|
||||
for($month = 1; $month<=3; $month++) {
|
||||
$sql_payments = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS payment_total_amount_for_month FROM payments, invoices WHERE payments.invoice_id = invoices.invoice_id AND YEAR(payment_date) = $year AND MONTH(payment_date) = $month AND payments.company_id = $session_company_id");
|
||||
$row = mysqli_fetch_array($sql_payments);
|
||||
$payment_total_amount_for_month = $row['payment_total_amount_for_month'];
|
||||
|
||||
$sql_revenues = mysqli_query($mysqli,"SELECT SUM(revenue_amount) AS revenue_total_amount_for_month FROM revenues WHERE category_id > 0 AND YEAR(revenue_date) = $year AND MONTH(revenue_date) = $month AND revenues.company_id = $session_company_id");
|
||||
$row = mysqli_fetch_array($sql_revenues);
|
||||
$revenue_total_amount_for_month = $row['revenue_total_amount_for_month'];
|
||||
|
||||
$payment_total_amount_for_month = $payment_total_amount_for_month + $revenue_total_amount_for_month;
|
||||
|
||||
$payment_total_amount_for_quarter_one = $payment_total_amount_for_quarter_one + $payment_total_amount_for_month;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<th class="text-right text-monospace">$<?php echo number_format($payment_total_amount_for_quarter_one,2); ?></th>
|
||||
|
||||
<?php
|
||||
|
||||
for($month = 4; $month<=6; $month++) {
|
||||
$sql_payments = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS payment_total_amount_for_month FROM payments, invoices WHERE payments.invoice_id = invoices.invoice_id AND YEAR(payment_date) = $year AND MONTH(payment_date) = $month AND payments.company_id = $session_company_id");
|
||||
$row = mysqli_fetch_array($sql_payments);
|
||||
$payment_total_amount_for_month = $row['payment_total_amount_for_month'];
|
||||
|
||||
$sql_revenues = mysqli_query($mysqli,"SELECT SUM(revenue_amount) AS revenue_total_amount_for_month FROM revenues WHERE category_id > 0 AND YEAR(revenue_date) = $year AND MONTH(revenue_date) = $month AND revenues.company_id = $session_company_id");
|
||||
$row = mysqli_fetch_array($sql_revenues);
|
||||
$revenue_total_amount_for_month = $row['revenue_total_amount_for_month'];
|
||||
|
||||
$payment_total_amount_for_month = $payment_total_amount_for_month + $revenue_total_amount_for_month;
|
||||
|
||||
$payment_total_amount_for_quarter_two = $payment_total_amount_for_quarter_two + $payment_total_amount_for_month;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<th class="text-right text-monospace">$<?php echo number_format($payment_total_amount_for_quarter_two,2); ?></th>
|
||||
|
||||
<?php
|
||||
|
||||
for($month = 7; $month<=9; $month++) {
|
||||
$sql_payments = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS payment_total_amount_for_month FROM payments, invoices WHERE payments.invoice_id = invoices.invoice_id AND YEAR(payment_date) = $year AND MONTH(payment_date) = $month AND payments.company_id = $session_company_id");
|
||||
$row = mysqli_fetch_array($sql_payments);
|
||||
$payment_total_amount_for_month = $row['payment_total_amount_for_month'];
|
||||
|
||||
$sql_revenues = mysqli_query($mysqli,"SELECT SUM(revenue_amount) AS revenue_total_amount_for_month FROM revenues WHERE category_id > 0 AND YEAR(revenue_date) = $year AND MONTH(revenue_date) = $month AND revenues.company_id = $session_company_id");
|
||||
$row = mysqli_fetch_array($sql_revenues);
|
||||
$revenue_total_amount_for_month = $row['revenue_total_amount_for_month'];
|
||||
|
||||
$payment_total_amount_for_month = $payment_total_amount_for_month + $revenue_total_amount_for_month;
|
||||
|
||||
$payment_total_amount_for_quarter_three = $payment_total_amount_for_quarter_three + $payment_total_amount_for_month;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<th class="text-right text-monospace">$<?php echo number_format($payment_total_amount_for_quarter_three,2); ?></th>
|
||||
|
||||
<?php
|
||||
|
||||
for($month = 10; $month<=12; $month++) {
|
||||
$sql_payments = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS payment_total_amount_for_month FROM payments, invoices WHERE payments.invoice_id = invoices.invoice_id AND YEAR(payment_date) = $year AND MONTH(payment_date) = $month AND payments.company_id = $session_company_id");
|
||||
$row = mysqli_fetch_array($sql_payments);
|
||||
$payment_total_amount_for_month = $row['payment_total_amount_for_month'];
|
||||
|
||||
$sql_revenues = mysqli_query($mysqli,"SELECT SUM(revenue_amount) AS revenue_total_amount_for_month FROM revenues WHERE category_id > 0 AND YEAR(revenue_date) = $year AND MONTH(revenue_date) = $month AND revenues.company_id = $session_company_id");
|
||||
$row = mysqli_fetch_array($sql_revenues);
|
||||
$revenue_total_amount_for_month = $row['revenue_total_amount_for_month'];
|
||||
|
||||
$payment_total_amount_for_month = $payment_total_amount_for_month + $revenue_total_amount_for_month;
|
||||
|
||||
$payment_total_amount_for_quarter_four = $payment_total_amount_for_quarter_four + $payment_total_amount_for_month;
|
||||
}
|
||||
|
||||
$total_payments_for_all_four_quarters = $payment_total_amount_for_quarter_one + $payment_total_amount_for_quarter_two + $payment_total_amount_for_quarter_three + $payment_total_amount_for_quarter_four;
|
||||
|
||||
?>
|
||||
|
||||
<th class="text-right text-monospace">$<?php echo number_format($payment_total_amount_for_quarter_four,2); ?></th>
|
||||
|
||||
<th class="text-right text-monospace">$<?php echo number_format($total_payments_for_all_four_quarters,2); ?></th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<th><br><br>Expenses</th>
|
||||
<th colspan="5"></th>
|
||||
</tr>
|
||||
<?php
|
||||
while($row = mysqli_fetch_array($sql_categories_expense)){
|
||||
$category_id = $row['category_id'];
|
||||
$category_name = $row['category_name'];
|
||||
?>
|
||||
|
||||
<tr>
|
||||
<td><?php echo $category_name; ?></td>
|
||||
|
||||
<?php
|
||||
|
||||
for($month = 1; $month<=3; $month++) {
|
||||
$sql_expenses = mysqli_query($mysqli,"SELECT SUM(expense_amount) AS expense_amount_for_month FROM expenses WHERE category_id = $category_id AND YEAR(expense_date) = $year AND MONTH(expense_date) = $month");
|
||||
$row = mysqli_fetch_array($sql_expenses);
|
||||
$expense_amount_for_quarter_one = $expense_amount_for_quarter_one + $row['expense_amount_for_month'];
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<td class="text-right text-monospace">$<?php echo number_format($expense_amount_for_quarter_one,2); ?></td>
|
||||
|
||||
<?php
|
||||
|
||||
for($month = 4; $month<=6; $month++) {
|
||||
$sql_expenses = mysqli_query($mysqli,"SELECT SUM(expense_amount) AS expense_amount_for_month FROM expenses WHERE category_id = $category_id AND YEAR(expense_date) = $year AND MONTH(expense_date) = $month");
|
||||
$row = mysqli_fetch_array($sql_expenses);
|
||||
$expense_amount_for_quarter_two = $expense_amount_for_quarter_two + $row['expense_amount_for_month'];
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<td class="text-right text-monospace">$<?php echo number_format($expense_amount_for_quarter_two,2); ?></td>
|
||||
|
||||
<?php
|
||||
|
||||
for($month = 7; $month<=9; $month++) {
|
||||
$sql_expenses = mysqli_query($mysqli,"SELECT SUM(expense_amount) AS expense_amount_for_month FROM expenses WHERE category_id = $category_id AND YEAR(expense_date) = $year AND MONTH(expense_date) = $month");
|
||||
$row = mysqli_fetch_array($sql_expenses);
|
||||
$expense_amount_for_quarter_three = $expense_amount_for_quarter_three + $row['expense_amount_for_month'];
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<td class="text-right text-monospace">$<?php echo number_format($expense_amount_for_quarter_three,2); ?></td>
|
||||
|
||||
<?php
|
||||
|
||||
for($month = 10; $month<=12; $month++) {
|
||||
$sql_expenses = mysqli_query($mysqli,"SELECT SUM(expense_amount) AS expense_amount_for_month FROM expenses WHERE category_id = $category_id AND YEAR(expense_date) = $year AND MONTH(expense_date) = $month");
|
||||
$row = mysqli_fetch_array($sql_expenses);
|
||||
$expense_amount_for_quarter_four = $expense_amount_for_quarter_four + $row['expense_amount_for_month'];
|
||||
}
|
||||
|
||||
$total_expenses_for_all_four_quarters = $expense_amount_for_quarter_one + $expense_amount_for_quarter_two + $expense_amount_for_quarter_three + $expense_amount_for_quarter_four;
|
||||
|
||||
?>
|
||||
|
||||
<td class="text-right text-monospace">$<?php echo number_format($expense_amount_for_quarter_four,2); ?></td>
|
||||
|
||||
<td class="text-right text-monospace">$<?php echo number_format($total_expenses_for_all_four_quarters,2); ?></td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
|
||||
$expense_amount_for_quarter_one = 0;
|
||||
$expense_amount_for_quarter_two = 0;
|
||||
$expense_amount_for_quarter_three = 0;
|
||||
$expense_amount_for_quarter_four = 0;
|
||||
$total_expense_for_all_months = 0;
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<tr>
|
||||
<th>Total Expenses<br><br><br></th>
|
||||
<?php
|
||||
|
||||
for($month = 1; $month<=3; $month++) {
|
||||
$sql_expenses = mysqli_query($mysqli,"SELECT SUM(expense_amount) AS expense_total_amount_for_month FROM expenses WHERE category_id > 0 AND YEAR(expense_date) = $year AND MONTH(expense_date) = $month AND vendor_id > 0 AND company_id = $session_company_id");
|
||||
$row = mysqli_fetch_array($sql_expenses);
|
||||
$expense_total_amount_for_quarter_one = $expense_total_amount_for_quarter_one + $row['expense_total_amount_for_month'];
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<th class="text-right text-monospace">$<?php echo number_format($expense_total_amount_for_quarter_one,2); ?></th>
|
||||
|
||||
<?php
|
||||
|
||||
for($month = 4; $month<=6; $month++) {
|
||||
$sql_expenses = mysqli_query($mysqli,"SELECT SUM(expense_amount) AS expense_total_amount_for_month FROM expenses WHERE category_id > 0 AND YEAR(expense_date) = $year AND MONTH(expense_date) = $month AND vendor_id > 0 AND company_id = $session_company_id");
|
||||
$row = mysqli_fetch_array($sql_expenses);
|
||||
$expense_total_amount_for_quarter_two = $expense_total_amount_for_quarter_two + $row['expense_total_amount_for_month'];
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<th class="text-right text-monospace">$<?php echo number_format($expense_total_amount_for_quarter_two,2); ?></th>
|
||||
|
||||
<?php
|
||||
|
||||
for($month = 7; $month<=9; $month++) {
|
||||
$sql_expenses = mysqli_query($mysqli,"SELECT SUM(expense_amount) AS expense_total_amount_for_month FROM expenses WHERE category_id > 0 AND YEAR(expense_date) = $year AND MONTH(expense_date) = $month AND vendor_id > 0 AND company_id = $session_company_id");
|
||||
$row = mysqli_fetch_array($sql_expenses);
|
||||
$expense_total_amount_for_quarter_three = $expense_total_amount_for_quarter_three + $row['expense_total_amount_for_month'];
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<th class="text-right text-monospace">$<?php echo number_format($expense_total_amount_for_quarter_three,2); ?></th>
|
||||
|
||||
<?php
|
||||
|
||||
for($month = 10; $month<=12; $month++) {
|
||||
$sql_expenses = mysqli_query($mysqli,"SELECT SUM(expense_amount) AS expense_total_amount_for_month FROM expenses WHERE category_id > 0 AND YEAR(expense_date) = $year AND MONTH(expense_date) = $month AND vendor_id > 0 AND company_id = $session_company_id");
|
||||
$row = mysqli_fetch_array($sql_expenses);
|
||||
$expense_total_amount_for_quarter_four = $expense_total_amount_for_quarter_four + $row['expense_total_amount_for_month'];
|
||||
}
|
||||
|
||||
$total_expenses_for_all_four_quarters = $expense_total_amount_for_quarter_one + $expense_total_amount_for_quarter_two + $expense_total_amount_for_quarter_three + $expense_total_amount_for_quarter_four;
|
||||
|
||||
?>
|
||||
|
||||
<th class="text-right text-monospace">$<?php echo number_format($expense_total_amount_for_quarter_four,2); ?></th>
|
||||
|
||||
<th class="text-right text-monospace">$<?php echo number_format($total_expenses_for_all_four_quarters,2); ?></th>
|
||||
</tr>
|
||||
<tr>
|
||||
<?php
|
||||
$net_profit_quarter_one = $payment_total_amount_for_quarter_one - $expense_total_amount_for_quarter_one;
|
||||
$net_profit_quarter_two = $payment_total_amount_for_quarter_two - $expense_total_amount_for_quarter_two;
|
||||
$net_profit_quarter_three = $payment_total_amount_for_quarter_three - $expense_total_amount_for_quarter_three;
|
||||
$net_profit_quarter_four = $payment_total_amount_for_quarter_four - $expense_total_amount_for_quarter_four;
|
||||
$net_profit_year = $total_payments_for_all_four_quarters - $total_expenses_for_all_four_quarters;
|
||||
?>
|
||||
|
||||
<th>Net Profit</th>
|
||||
<th class="text-right text-monospace">$<?php echo number_format($net_profit_quarter_one,2); ?></th>
|
||||
<th class="text-right text-monospace">$<?php echo number_format($net_profit_quarter_two,2); ?></th>
|
||||
<th class="text-right text-monospace">$<?php echo number_format($net_profit_quarter_three,2); ?></th>
|
||||
<th class="text-right text-monospace">$<?php echo number_format($net_profit_quarter_four,2); ?></th>
|
||||
<th class="text-right text-monospace">$<?php echo number_format($net_profit_year,2); ?></th>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<?php include("footer.php");
|
||||
|
|
@ -195,8 +195,8 @@ if(isset($_GET['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="text" class="form-control" style="text-align: center;" name="qty"></td>
|
||||
<td><input type="text" class="form-control" style="text-align: right;" name="price"></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>
|
||||
<select dir="rtl" class="form-control" name="tax">
|
||||
<option value="0.00">None</option>
|
||||
|
|
|
|||
|
|
@ -125,6 +125,7 @@
|
|||
</button>
|
||||
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
|
||||
<a class="dropdown-item" href="recurring_invoice.php?recurring_id=<?php echo $recurring_id; ?>">Edit</a>
|
||||
<a class="dropdown-item" href="post.php?force_recurring=<?php echo $recurring_id; ?>">Force</a>
|
||||
<?php if($recurring_status == 1){ ?>
|
||||
<a class="dropdown-item" href="post.php?recurring_deactivate=<?php echo $recurring_id; ?>">Deactivate</a>
|
||||
<?php }else{ ?>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,140 @@
|
|||
<?php include("header.php"); ?>
|
||||
<?php
|
||||
|
||||
if(isset($_GET['year'])){
|
||||
$year = intval($_GET['year']);
|
||||
}else{
|
||||
$year = date('Y');
|
||||
}
|
||||
|
||||
$sql_payment_years = mysqli_query($mysqli,"SELECT DISTINCT YEAR(invoice_date) AS payment_year FROM invoices UNION SELECT DISTINCT YEAR(revenue_date) AS payment_year FROM revenues ORDER BY payment_year DESC");
|
||||
|
||||
$sql_categories = mysqli_query($mysqli,"SELECT * FROM categories WHERE category_type = 'Income' AND company_id = $session_company_id ORDER BY category_name ASC");
|
||||
|
||||
?>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header bg-dark text-white">
|
||||
<h6 class="float-left mt-1"><i class="fa fa-fw fa-coins mr-2"></i>Income Summary</h6>
|
||||
<button type="button" class="btn btn-primary btn-sm float-right d-print-none" onclick="window.print();"><i class="fas fa-fw fa-print"></i> Print</button>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form class="mb-3">
|
||||
<select onchange="this.form.submit()" class="form-control" 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>
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-sm">
|
||||
<thead class="text-dark">
|
||||
<tr>
|
||||
<th>Category</th>
|
||||
<th class="text-right">January</th>
|
||||
<th class="text-right">February</th>
|
||||
<th class="text-right">March</th>
|
||||
<th class="text-right">April</th>
|
||||
<th class="text-right">May</th>
|
||||
<th class="text-right">June</th>
|
||||
<th class="text-right">July</th>
|
||||
<th class="text-right">August</th>
|
||||
<th class="text-right">September</th>
|
||||
<th class="text-right">October</th>
|
||||
<th class="text-right">November</th>
|
||||
<th class="text-right">December</th>
|
||||
<th class="text-right">Total</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
while($row = mysqli_fetch_array($sql_categories)){
|
||||
$category_id = $row['category_id'];
|
||||
$category_name = $row['category_name'];
|
||||
?>
|
||||
|
||||
<tr>
|
||||
<td><?php echo $category_name; ?></td>
|
||||
|
||||
<?php
|
||||
|
||||
for($month = 1; $month<=12; $month++) {
|
||||
//Payments to Invoices
|
||||
$sql_payments = mysqli_query($mysqli,"SELECT SUM(invoice_amount) AS payment_amount_for_month FROM invoices WHERE invoices.category_id = $category_id AND YEAR(invoice_date) = $year AND MONTH(invoice_date) = $month");
|
||||
$row = mysqli_fetch_array($sql_payments);
|
||||
$payment_amount_for_month = $row['payment_amount_for_month'];
|
||||
|
||||
//Revenues
|
||||
$sql_revenues = mysqli_query($mysqli,"SELECT SUM(revenue_amount) AS revenue_amount_for_month FROM revenues WHERE revenues.category_id = $category_id AND YEAR(revenue_date) = $year AND MONTH(revenue_date) = $month");
|
||||
$row = mysqli_fetch_array($sql_revenues);
|
||||
$revenues_amount_for_month = $row['revenue_amount_for_month'];
|
||||
|
||||
$payment_amount_for_month = $payment_amount_for_month + $revenues_amount_for_month;
|
||||
|
||||
$total_payment_for_all_months = $payment_amount_for_month + $total_payment_for_all_months;
|
||||
|
||||
|
||||
?>
|
||||
<td class="text-right text-monospace">$<?php echo number_format($payment_amount_for_month,2); ?></td>
|
||||
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<td class="text-right text-monospace">$<?php echo number_format($total_payment_for_all_months,2); ?></td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
|
||||
$total_payment_for_all_months = 0;
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<tr>
|
||||
<th>Total</th>
|
||||
<?php
|
||||
|
||||
for($month = 1; $month<=12; $month++) {
|
||||
$sql_payments = mysqli_query($mysqli,"SELECT SUM(invoice_amount) AS payment_total_amount_for_month FROM invoices WHERE YEAR(invoice_date) = $year AND MONTH(invoice_date) = $month AND invoices.company_id = $session_company_id");
|
||||
$row = mysqli_fetch_array($sql_payments);
|
||||
$payment_total_amount_for_month = $row['payment_total_amount_for_month'];
|
||||
|
||||
$sql_revenues = mysqli_query($mysqli,"SELECT SUM(revenue_amount) AS revenue_amount_for_month FROM revenues WHERE category_id > 0 AND YEAR(revenue_date) = $year AND MONTH(revenue_date) = $month AND revenues.company_id = $session_company_id");
|
||||
$row = mysqli_fetch_array($sql_revenues);
|
||||
$revenues_total_amount_for_month = $row['revenue_amount_for_month'];
|
||||
|
||||
$payment_total_amount_for_month = $payment_total_amount_for_month + $revenues_total_amount_for_month;
|
||||
|
||||
|
||||
$total_payment_for_all_months = $payment_total_amount_for_month + $total_payment_for_all_months;
|
||||
|
||||
?>
|
||||
|
||||
<th class="text-right text-monospace">$<?php echo number_format($payment_total_amount_for_month,2); ?></th>
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<th class="text-right text-monospace">$<?php echo number_format($total_payment_for_all_months,2); ?></th>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include("footer.php");
|
||||
|
|
@ -47,6 +47,14 @@
|
|||
Quote
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li class="nav-item">
|
||||
<a class="nav-link <?php if(basename($_SERVER["REQUEST_URI"]) == "settings-ticket.php") { echo "active"; } ?>"
|
||||
href="settings-ticket.php">
|
||||
<i class="fa fa-fw fa-2x fa-tag"></i><br>
|
||||
Ticket
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li class="nav-item">
|
||||
<a class="nav-link <?php if(basename($_SERVER["REQUEST_URI"]) == "settings-backup.php") { echo "active"; } ?>"
|
||||
|
|
|
|||
|
|
@ -0,0 +1,39 @@
|
|||
<?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-tag mr-2"></i>Ticket Settings</h6>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form class="p-3" action="post.php" method="post" autocomplete="off">
|
||||
|
||||
<div class="form-group">
|
||||
<label>Ticket Prefix</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-barcode"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="config_ticket_prefix" placeholder="Ticket Prefix" value="<?php echo $config_ticket_prefix; ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Next Number</label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-barcode"></i></span>
|
||||
</div>
|
||||
<input type="number" min="0" class="form-control" name="config_ticket_next_number" placeholder="Next Ticket Number" value="<?php echo $config_ticket_next_number; ?>" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<hr>
|
||||
<button type="submit" name="edit_ticket_settings" class="btn btn-primary">Save</button>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php include("footer.php");
|
||||
14
setup.php
14
setup.php
|
|
@ -1,6 +1,9 @@
|
|||
<?php
|
||||
|
||||
include("functions.php");
|
||||
include("functions.php");
|
||||
|
||||
$_SESSION['alert_message'] = '';
|
||||
$_SESSION['alert_type'] = "warning";
|
||||
|
||||
if(isset($_POST['add_database'])){
|
||||
|
||||
|
|
@ -112,7 +115,7 @@ if(isset($_POST['add_company_settings'])){
|
|||
|
||||
mysqli_query($mysqli,"INSERT INTO user_companies SET user_id = $user_id, company_id = $company_id");
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO settings SET company_id = $company_id, config_company_name = '$config_company_name', config_company_address = '$config_company_address', config_company_city = '$config_company_city', config_company_state = '$config_company_state', config_company_zip = '$config_company_zip', config_company_phone = $config_company_phone, config_company_site = '$config_company_site', config_start_page = 'dashboard.php', config_invoice_prefix = 'INV-', config_invoice_next_number = 1, config_invoice_overdue_reminders = '1,3,7', config_quote_prefix = 'QUO-', config_quote_next_number = 1, config_api_key = '$config_api_key', config_recurring_auto_send_invoice = 1, config_default_net_terms = 7, config_send_invoice_reminders = 0, config_enable_cron = 0");
|
||||
mysqli_query($mysqli,"INSERT INTO settings SET company_id = $company_id, config_company_name = '$config_company_name', config_company_address = '$config_company_address', config_company_city = '$config_company_city', config_company_state = '$config_company_state', config_company_zip = '$config_company_zip', config_company_phone = $config_company_phone, config_company_site = '$config_company_site', config_start_page = 'dashboard.php', config_invoice_prefix = 'INV-', config_invoice_next_number = 1, config_invoice_overdue_reminders = '1,3,7', config_quote_prefix = 'QUO-', config_quote_next_number = 1, config_api_key = '$config_api_key', config_recurring_auto_send_invoice = 1, config_default_net_terms = 7, config_send_invoice_reminders = 0, config_enable_cron = 0, config_ticket_next_number = 1");
|
||||
|
||||
//Create Some Data
|
||||
|
||||
|
|
@ -206,8 +209,7 @@ if(isset($_POST['add_company_settings'])){
|
|||
|
||||
<div class="container">
|
||||
<?php include("config.php"); ?>
|
||||
<?php if(isset($_GET['database'])){ ?>
|
||||
|
||||
|
||||
<?php
|
||||
//Alert Feedback
|
||||
if(!empty($_SESSION['alert_message'])){
|
||||
|
|
@ -221,7 +223,9 @@ if(isset($_POST['add_company_settings'])){
|
|||
$_SESSION['alert_message'] = '';
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
<?php if(isset($_GET['database'])){ ?>
|
||||
|
||||
<div class="card mb-3">
|
||||
<div class="card-header">
|
||||
<h6 class="mt-1"><i class="fa fa-fw fa-database"></i> Setup Database</h6>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,166 @@
|
|||
<?php include("config.php"); ?>
|
||||
|
||||
<?php
|
||||
|
||||
if(isset($_GET['ticket_id'])){
|
||||
$ticket_id = intval($_GET['ticket_id']);
|
||||
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM tickets, clients WHERE tickets.client_id = clients.client_id AND ticket_id = $ticket_id");
|
||||
|
||||
$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_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;
|
||||
}
|
||||
$ticket_prefix = $row['ticket_prefix'];
|
||||
$ticket_number = $row['ticket_number'];
|
||||
$ticket_category = $row['ticket_category'];
|
||||
$ticket_subject = $row['ticket_subject'];
|
||||
$ticket_details = $row['ticket_details'];
|
||||
$ticket_status = $row['ticket_status'];
|
||||
$ticket_created_at = $row['ticket_created_at'];
|
||||
$ticket_updated_at = $row['ticket_updated_at'];
|
||||
$ticket_closed_at = $row['ticket_closed_at'];
|
||||
$ticket_created_by = $row['ticket_created_by'];
|
||||
|
||||
if($ticket_status == "Open"){
|
||||
$ticket_badge_color = "primary";
|
||||
}elseif($ticket_status == "Working"){
|
||||
$ticket_badge_color = "success";
|
||||
}else{
|
||||
$ticket_badge_color = "secondary";
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<?php include("header.php"); ?>
|
||||
|
||||
<!-- Breadcrumbs-->
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item">
|
||||
<a href="tickets.php">Tickets</a>
|
||||
</li>
|
||||
<li class="breadcrumb-item active">Ticket Details</li>
|
||||
</ol>
|
||||
<div class="row">
|
||||
<div class="col-md-3">
|
||||
<div class="card mb-3">
|
||||
<div class="card-header">
|
||||
<h2>
|
||||
Ticket <?php echo $ticket_number; ?>
|
||||
</h2>
|
||||
<span class="p-2 badge badge-<?php echo $ticket_badge_color; ?>">
|
||||
<?php echo $ticket_status; ?>
|
||||
</span>
|
||||
|
||||
</div>
|
||||
<div class="card-body">
|
||||
|
||||
<div class="mb-4">
|
||||
<h4 class="text-secondary">Client</h4>
|
||||
<i class="fa fa-fw fa-user text-secondary ml-1 mr-2 mb-2"></i> <?php echo $client_name; ?>
|
||||
<br>
|
||||
<?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>
|
||||
<br>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
if(!empty($client_phone)){
|
||||
?>
|
||||
<i class="fa fa-fw fa-phone text-secondary ml-1 mr-2 mb-2"></i> <?php echo $client_phone; ?>
|
||||
<br>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
|
||||
<h4 class="text-secondary">Details</h4>
|
||||
<div class="ml-1"><i class="fa fa-fw fa-user text-secondary mr-2 mb-2"></i> <?php echo $ticket_created_by; ?></div>
|
||||
<div class="ml-1"><i class="fa fa-fw fa-clock text-secondary mr-2 mb-2"></i> <?php echo $ticket_created_at; ?></div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-9">
|
||||
|
||||
<div class="card mb-3">
|
||||
<div class="card-header">
|
||||
<h6 class="float-left mt-1"><?php echo $ticket_subject; ?></h6>
|
||||
<div class="dropdown dropleft text-center">
|
||||
<button class="btn btn-dark 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="client_print.php?client_id=<?php echo $client_id; ?>">Print</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<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>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p><?php echo $ticket_details; ?></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form action="post.php" method="post" autocomplete="off">
|
||||
<input type="hidden" name="ticket_id" value="<?php echo $ticket_id; ?>">
|
||||
<div class="form-group">
|
||||
<textarea rows="5" class="form-control" name="ticket_update"></textarea>
|
||||
</div>
|
||||
<button type="submit" name="add_ticket_update" class="btn btn-primary">Save</button>
|
||||
|
||||
</form>
|
||||
|
||||
<?php
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM ticket_updates WHERE ticket_id = $ticket_id");
|
||||
|
||||
while($row = mysqli_fetch_array($sql)){;
|
||||
$ticket_update_id = $row['ticket_update_id'];
|
||||
$ticket_update = $row['ticket_update'];
|
||||
$ticket_update_created_at = $row['ticket_update_created_at'];
|
||||
$user_id = $row['user_id'];
|
||||
|
||||
?>
|
||||
|
||||
<div class="card mb-3">
|
||||
<div class="card-body">
|
||||
<p class="blockquote"><?php echo $ticket_update; ?></p>
|
||||
</div>
|
||||
<div class="card-footer"><?php echo $ticket_update_created_at - $user_id; ?></div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<?php include("edit_ticket_modal.php"); ?>
|
||||
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<?php include("footer.php");
|
||||
|
|
@ -105,7 +105,7 @@
|
|||
?>
|
||||
|
||||
<tr>
|
||||
<td><a href="#" data-toggle="modal" data-target="#viewTicketModal<?php echo $ticket_id; ?>"><span class="badge badge-pill badge-secondary p-3"><?php echo $ticket_id; ?></span></a></td>
|
||||
<td><a href="ticket.php?ticket_id=<?php echo $ticket_id; ?>"><span class="badge badge-pill badge-secondary p-3"><?php echo $ticket_id; ?></span></a></td>
|
||||
<td><a href="client.php?client_id=<?php echo $client_id; ?>"><?php echo $client_name; ?></a></td>
|
||||
<td><?php echo $ticket_subject; ?></td>
|
||||
<td><?php echo $ticket_created_at; ?></td>
|
||||
|
|
|
|||
Loading…
Reference in New Issue