From 2d44222ad93d2b29e0f27c58e1435619cfa9d1a5 Mon Sep 17 00:00:00 2001 From: "johnny@pittpc.com" Date: Mon, 26 Aug 2019 17:14:11 -0400 Subject: [PATCH] Fixed incorrect account balance under add revenue --- add_revenue_modal.php | 30 +- get_settings.php | 3 - post.php | 30 +- settings-general.php | 18 +- setup.php | 2 +- vendor/datatables/dataTables.bootstrap4.css | 206 - vendor/datatables/dataTables.bootstrap4.js | 184 - .../datatables/dataTables.bootstrap4.min.css | 1 - .../datatables/dataTables.bootstrap4.min.js | 8 - vendor/datatables/jquery.dataTables.js | 15296 ---------------- vendor/datatables/jquery.dataTables.min.js | 166 - 11 files changed, 36 insertions(+), 15908 deletions(-) delete mode 100644 vendor/datatables/dataTables.bootstrap4.css delete mode 100644 vendor/datatables/dataTables.bootstrap4.js delete mode 100644 vendor/datatables/dataTables.bootstrap4.min.css delete mode 100644 vendor/datatables/dataTables.bootstrap4.min.js delete mode 100644 vendor/datatables/jquery.dataTables.js delete mode 100644 vendor/datatables/jquery.dataTables.min.js diff --git a/add_revenue_modal.php b/add_revenue_modal.php index 6b6474b1..288e2135 100644 --- a/add_revenue_modal.php +++ b/add_revenue_modal.php @@ -41,20 +41,24 @@ diff --git a/get_settings.php b/get_settings.php index f3d1e6f4..6e5e5e0a 100644 --- a/get_settings.php +++ b/get_settings.php @@ -5,8 +5,6 @@ $sql_settings = mysqli_query($mysqli,"SELECT * FROM settings WHERE company_id = $session_company_id"); $row = mysqli_fetch_array($sql_settings); -$config_start_page = $row['config_start_page']; - $config_company_name = $row['config_company_name']; $config_company_address = $row['config_company_address']; $config_company_city = $row['config_company_city']; @@ -19,7 +17,6 @@ if(strlen($config_company_phone)>2){ $config_company_site = $row['config_company_site']; $config_quote_footer = $row['config_quote_footer']; -$config_quote_email_subject = $row['config_quote_email_subject']; $config_quote_next_number = $row['config_quote_next_number']; $config_quote_prefix = $row['config_quote_prefix']; diff --git a/post.php b/post.php index 1ff34c29..8d75d4a5 100644 --- a/post.php +++ b/post.php @@ -22,16 +22,20 @@ if(isset($_POST['add_user'])){ $password = md5(mysqli_real_escape_string($mysqli,$_POST['password'])); $client_id = intval($_POST['client']); + mysqli_query($mysqli,"INSERT INTO users SET name = '$name', email = '$email', password = '$password', avatar = '$path', created_at = NOW(), client_id = $client_id"); + + $user_id = mysqli_insert_id($mysqli); + if($_FILES['file']['tmp_name']!='') { - $path = "uploads/users/"; + $path = "uploads/users/$user_id/"; $path = $path . time() . basename( $_FILES['file']['name']); $file_name = basename($path); move_uploaded_file($_FILES['file']['tmp_name'], $path); } - mysqli_query($mysqli,"INSERT INTO users SET name = '$name', email = '$email', password = '$password', avatar = '$path', created_at = NOW(), client_id = $client_id"); + mysqli_query($mysqli,"UPDATE users SET avatar = '$path' WHERE user_id = $user_id"); - $_SESSION['alert_message'] = "User added"; + $_SESSION['alert_message'] = "User $name created!"; header("Location: users.php"); @@ -55,7 +59,7 @@ if(isset($_POST['edit_user'])){ //delete old avatar file unlink($path); //Update with new path - $path = "uploads/users/"; + $path = "uploads/users/$user_id/"; $path = $path . basename( $_FILES['file']['name']); $file_name = basename($path); move_uploaded_file($_FILES['file']['tmp_name'], $path); @@ -63,7 +67,7 @@ if(isset($_POST['edit_user'])){ mysqli_query($mysqli,"UPDATE users SET name = '$name', email = '$email', password = '$password', avatar = '$path', updated_at = NOW() WHERE user_id = $user_id"); - $_SESSION['alert_message'] = "User updated"; + $_SESSION['alert_message'] = "User $name updated"; header("Location: users.php"); @@ -86,7 +90,7 @@ if(isset($_POST['add_company'])){ 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, config_ticket_next_number = 1, config_base_url = '$config_base_url'"); - $_SESSION['alert_message'] = "Company $name created!"; + $_SESSION['alert_message'] = "Company $name created!"; header("Location: companies.php"); @@ -111,7 +115,8 @@ if(isset($_GET['delete_company'])){ mysqli_query($mysqli,"DELETE FROM settings WHERE company_id = $company_id"); - $_SESSION['alert_message'] = "Company deleted"; + $_SESSION['alert_type'] = "danger"; + $_SESSION['alert_message'] = "Company deleted!"; header("Location: " . $_SERVER["HTTP_REFERER"]); @@ -123,9 +128,9 @@ if(isset($_POST['verify'])){ $currentcode = $_POST['code']; //code to validate, for example received from device if(TokenAuth6238::verify($session_token,$currentcode)){ - $_SESSION['alert_message'] = "VALID!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"; + $_SESSION['alert_message'] = "VALID!"; }else{ - $_SESSION['alert_message'] = "INVALID"; + $_SESSION['alert_message'] = "IN-VALID!"; } header("Location: " . $_SERVER["HTTP_REFERER"]); @@ -134,7 +139,6 @@ if(isset($_POST['verify'])){ if(isset($_POST['edit_general_settings'])){ - $config_start_page = strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_start_page'])); $config_base_url = strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_base_url'])); $config_api_key = strip_tags(mysqli_real_escape_string($mysqli,$_POST['config_api_key'])); @@ -150,7 +154,7 @@ if(isset($_POST['edit_general_settings'])){ move_uploaded_file($_FILES['file']['tmp_name'], $path); } - mysqli_query($mysqli,"UPDATE settings SET config_start_page = '$config_start_page', config_account_balance_threshold = '$config_account_balance_threshold', config_invoice_logo = '$path', config_api_key = '$config_api_key', config_base_url = '$config_base_url' WHERE company_id = $session_company_id"); + mysqli_query($mysqli,"UPDATE settings SET config_invoice_logo = '$path', config_api_key = '$config_api_key', config_base_url = '$config_base_url' WHERE company_id = $session_company_id"); $_SESSION['alert_message'] = "Settings updated"; @@ -272,7 +276,7 @@ if(isset($_POST['enable_2fa'])){ mysqli_query($mysqli,"UPDATE users SET token = '$token' WHERE user_id = $session_user_id"); - $_SESSION['alert_message'] = "2FA Enabled and Token Updated"; + $_SESSION['alert_message'] = "Two Factor Authentication Enabled and Token Updated, don't lose your code you will need this additionally to login"; header("Location: " . $_SERVER["HTTP_REFERER"]); @@ -282,7 +286,7 @@ if(isset($_POST['disable_2fa'])){ mysqli_query($mysqli,"UPDATE users SET token = '' WHERE user_id = $session_user_id"); - $_SESSION['alert_message'] = "2FA Disabled you can now login without an additional code"; + $_SESSION['alert_message'] = "Two Factor Authentication Disabled you can now login without TOTP Code"; header("Location: " . $_SERVER["HTTP_REFERER"]); diff --git a/settings-general.php b/settings-general.php index a0b7cb90..2395e598 100644 --- a/settings-general.php +++ b/settings-general.php @@ -8,22 +8,6 @@
-
- -
-
- -
- -
-
@@ -31,7 +15,7 @@
- +
diff --git a/setup.php b/setup.php index 385771ae..ad06c997 100644 --- a/setup.php +++ b/setup.php @@ -129,7 +129,7 @@ if(isset($_POST['add_user'])){ $email = strip_tags(mysqli_real_escape_string($mysqli,$_POST['email'])); $password = md5(mysqli_real_escape_string($mysqli,$_POST['password'])); - mysqli_query($mysqli,"INSERT INTO users SET name = '$name', email = '$email', password = '$password', avatar = '$path', created_at = NOW()"); + mysqli_query($mysqli,"INSERT INTO users SET name = '$name', email = '$email', password = '$password', created_at = NOW()"); $user_id = mysqli_insert_id($mysqli); diff --git a/vendor/datatables/dataTables.bootstrap4.css b/vendor/datatables/dataTables.bootstrap4.css deleted file mode 100644 index 84ec2036..00000000 --- a/vendor/datatables/dataTables.bootstrap4.css +++ /dev/null @@ -1,206 +0,0 @@ -table.dataTable { - clear: both; - margin-top: 6px !important; - margin-bottom: 6px !important; - max-width: none !important; - border-collapse: separate !important; - border-spacing: 0; -} -table.dataTable td, -table.dataTable th { - -webkit-box-sizing: content-box; - box-sizing: content-box; -} -table.dataTable td.dataTables_empty, -table.dataTable th.dataTables_empty { - text-align: center; -} -table.dataTable.nowrap th, -table.dataTable.nowrap td { - white-space: nowrap; -} - -div.dataTables_wrapper div.dataTables_length label { - font-weight: normal; - text-align: left; - white-space: nowrap; -} -div.dataTables_wrapper div.dataTables_length select { - width: auto; - display: inline-block; -} -div.dataTables_wrapper div.dataTables_filter { - text-align: right; -} -div.dataTables_wrapper div.dataTables_filter label { - font-weight: normal; - white-space: nowrap; - text-align: left; -} -div.dataTables_wrapper div.dataTables_filter input { - margin-left: 0.5em; - display: inline-block; - width: auto; -} -div.dataTables_wrapper div.dataTables_info { - padding-top: 0.85em; - white-space: nowrap; -} -div.dataTables_wrapper div.dataTables_paginate { - margin: 0; - white-space: nowrap; - text-align: right; -} -div.dataTables_wrapper div.dataTables_paginate ul.pagination { - margin: 2px 0; - white-space: nowrap; - justify-content: flex-end; -} -div.dataTables_wrapper div.dataTables_processing { - position: absolute; - top: 50%; - left: 50%; - width: 200px; - margin-left: -100px; - margin-top: -26px; - text-align: center; - padding: 1em 0; -} - -table.dataTable thead > tr > th.sorting_asc, table.dataTable thead > tr > th.sorting_desc, table.dataTable thead > tr > th.sorting, -table.dataTable thead > tr > td.sorting_asc, -table.dataTable thead > tr > td.sorting_desc, -table.dataTable thead > tr > td.sorting { - padding-right: 30px; -} -table.dataTable thead > tr > th:active, -table.dataTable thead > tr > td:active { - outline: none; -} -table.dataTable thead .sorting, -table.dataTable thead .sorting_asc, -table.dataTable thead .sorting_desc, -table.dataTable thead .sorting_asc_disabled, -table.dataTable thead .sorting_desc_disabled { - cursor: pointer; - position: relative; -} -table.dataTable thead .sorting:before, table.dataTable thead .sorting:after, -table.dataTable thead .sorting_asc:before, -table.dataTable thead .sorting_asc:after, -table.dataTable thead .sorting_desc:before, -table.dataTable thead .sorting_desc:after, -table.dataTable thead .sorting_asc_disabled:before, -table.dataTable thead .sorting_asc_disabled:after, -table.dataTable thead .sorting_desc_disabled:before, -table.dataTable thead .sorting_desc_disabled:after { - position: absolute; - bottom: 0.9em; - display: block; - opacity: 0.3; -} -table.dataTable thead .sorting:before, -table.dataTable thead .sorting_asc:before, -table.dataTable thead .sorting_desc:before, -table.dataTable thead .sorting_asc_disabled:before, -table.dataTable thead .sorting_desc_disabled:before { - right: 1em; - content: "\2191"; -} -table.dataTable thead .sorting:after, -table.dataTable thead .sorting_asc:after, -table.dataTable thead .sorting_desc:after, -table.dataTable thead .sorting_asc_disabled:after, -table.dataTable thead .sorting_desc_disabled:after { - right: 0.5em; - content: "\2193"; -} -table.dataTable thead .sorting_asc:before, -table.dataTable thead .sorting_desc:after { - opacity: 1; -} -table.dataTable thead .sorting_asc_disabled:before, -table.dataTable thead .sorting_desc_disabled:after { - opacity: 0; -} - -div.dataTables_scrollHead table.dataTable { - margin-bottom: 0 !important; -} - -div.dataTables_scrollBody table { - border-top: none; - margin-top: 0 !important; - margin-bottom: 0 !important; -} -div.dataTables_scrollBody table thead .sorting:before, -div.dataTables_scrollBody table thead .sorting_asc:before, -div.dataTables_scrollBody table thead .sorting_desc:before, -div.dataTables_scrollBody table thead .sorting:after, -div.dataTables_scrollBody table thead .sorting_asc:after, -div.dataTables_scrollBody table thead .sorting_desc:after { - display: none; -} -div.dataTables_scrollBody table tbody tr:first-child th, -div.dataTables_scrollBody table tbody tr:first-child td { - border-top: none; -} - -div.dataTables_scrollFoot > .dataTables_scrollFootInner { - box-sizing: content-box; -} -div.dataTables_scrollFoot > .dataTables_scrollFootInner > table { - margin-top: 0 !important; - border-top: none; -} - -@media screen and (max-width: 767px) { - div.dataTables_wrapper div.dataTables_length, - div.dataTables_wrapper div.dataTables_filter, - div.dataTables_wrapper div.dataTables_info, - div.dataTables_wrapper div.dataTables_paginate { - text-align: center; - } -} -table.dataTable.table-sm > thead > tr > th { - padding-right: 20px; -} -table.dataTable.table-sm .sorting:before, -table.dataTable.table-sm .sorting_asc:before, -table.dataTable.table-sm .sorting_desc:before { - top: 5px; - right: 0.85em; -} -table.dataTable.table-sm .sorting:after, -table.dataTable.table-sm .sorting_asc:after, -table.dataTable.table-sm .sorting_desc:after { - top: 5px; -} - -table.table-bordered.dataTable th, -table.table-bordered.dataTable td { - border-left-width: 0; -} -table.table-bordered.dataTable th:last-child, table.table-bordered.dataTable th:last-child, -table.table-bordered.dataTable td:last-child, -table.table-bordered.dataTable td:last-child { - border-right-width: 0; -} -table.table-bordered.dataTable tbody th, -table.table-bordered.dataTable tbody td { - border-bottom-width: 0; -} - -div.dataTables_scrollHead table.table-bordered { - border-bottom-width: 0; -} - -div.table-responsive > div.dataTables_wrapper > div.row { - margin: 0; -} -div.table-responsive > div.dataTables_wrapper > div.row > div[class^="col-"]:first-child { - padding-left: 0; -} -div.table-responsive > div.dataTables_wrapper > div.row > div[class^="col-"]:last-child { - padding-right: 0; -} diff --git a/vendor/datatables/dataTables.bootstrap4.js b/vendor/datatables/dataTables.bootstrap4.js deleted file mode 100644 index f2d2ad58..00000000 --- a/vendor/datatables/dataTables.bootstrap4.js +++ /dev/null @@ -1,184 +0,0 @@ -/*! DataTables Bootstrap 4 integration - * ©2011-2017 SpryMedia Ltd - datatables.net/license - */ - -/** - * DataTables integration for Bootstrap 4. This requires Bootstrap 4 and - * DataTables 1.10 or newer. - * - * This file sets the defaults and adds options to DataTables to style its - * controls using Bootstrap. See http://datatables.net/manual/styling/bootstrap - * for further information. - */ -(function( factory ){ - if ( typeof define === 'function' && define.amd ) { - // AMD - define( ['jquery', 'datatables.net'], function ( $ ) { - return factory( $, window, document ); - } ); - } - else if ( typeof exports === 'object' ) { - // CommonJS - module.exports = function (root, $) { - if ( ! root ) { - root = window; - } - - if ( ! $ || ! $.fn.dataTable ) { - // Require DataTables, which attaches to jQuery, including - // jQuery if needed and have a $ property so we can access the - // jQuery object that is used - $ = require('datatables.net')(root, $).$; - } - - return factory( $, root, root.document ); - }; - } - else { - // Browser - factory( jQuery, window, document ); - } -}(function( $, window, document, undefined ) { -'use strict'; -var DataTable = $.fn.dataTable; - - -/* Set the defaults for DataTables initialisation */ -$.extend( true, DataTable.defaults, { - dom: - "<'row'<'col-sm-12 col-md-6'l><'col-sm-12 col-md-6'f>>" + - "<'row'<'col-sm-12'tr>>" + - "<'row'<'col-sm-12 col-md-5'i><'col-sm-12 col-md-7'p>>", - renderer: 'bootstrap' -} ); - - -/* Default class modification */ -$.extend( DataTable.ext.classes, { - sWrapper: "dataTables_wrapper dt-bootstrap4", - sFilterInput: "form-control form-control-sm", - sLengthSelect: "custom-select custom-select-sm form-control form-control-sm", - sProcessing: "dataTables_processing card", - sPageButton: "paginate_button page-item" -} ); - - -/* Bootstrap paging button renderer */ -DataTable.ext.renderer.pageButton.bootstrap = function ( settings, host, idx, buttons, page, pages ) { - var api = new DataTable.Api( settings ); - var classes = settings.oClasses; - var lang = settings.oLanguage.oPaginate; - var aria = settings.oLanguage.oAria.paginate || {}; - var btnDisplay, btnClass, counter=0; - - var attach = function( container, buttons ) { - var i, ien, node, button; - var clickHandler = function ( e ) { - e.preventDefault(); - if ( !$(e.currentTarget).hasClass('disabled') && api.page() != e.data.action ) { - api.page( e.data.action ).draw( 'page' ); - } - }; - - for ( i=0, ien=buttons.length ; i 0 ? - '' : ' disabled'); - break; - - case 'previous': - btnDisplay = lang.sPrevious; - btnClass = button + (page > 0 ? - '' : ' disabled'); - break; - - case 'next': - btnDisplay = lang.sNext; - btnClass = button + (page < pages-1 ? - '' : ' disabled'); - break; - - case 'last': - btnDisplay = lang.sLast; - btnClass = button + (page < pages-1 ? - '' : ' disabled'); - break; - - default: - btnDisplay = button + 1; - btnClass = page === button ? - 'active' : ''; - break; - } - - if ( btnDisplay ) { - node = $('
  • ', { - 'class': classes.sPageButton+' '+btnClass, - 'id': idx === 0 && typeof button === 'string' ? - settings.sTableId +'_'+ button : - null - } ) - .append( $('', { - 'href': '#', - 'aria-controls': settings.sTableId, - 'aria-label': aria[ button ], - 'data-dt-idx': counter, - 'tabindex': settings.iTabIndex, - 'class': 'page-link' - } ) - .html( btnDisplay ) - ) - .appendTo( container ); - - settings.oApi._fnBindAction( - node, {action: button}, clickHandler - ); - - counter++; - } - } - } - }; - - // IE9 throws an 'unknown error' if document.activeElement is used - // inside an iframe or frame. - var activeEl; - - try { - // Because this approach is destroying and recreating the paging - // elements, focus is lost on the select button which is bad for - // accessibility. So we want to restore focus once the draw has - // completed - activeEl = $(host).find(document.activeElement).data('dt-idx'); - } - catch (e) {} - - attach( - $(host).empty().html('