From 0c4021fd231d765adc281a5b1c1980c26676fce2 Mon Sep 17 00:00:00 2001 From: "johnny@pittpc.com" Date: Sun, 11 Aug 2019 13:42:35 -0400 Subject: [PATCH] reworked transfers, added revenues to add income in other ways besides just invoices, reports now uses a compact table to see all data clearly and some other minor fixes. --- README.md | 4 +- accounts.php | 6 +- add_expense_copy_modal.php | 12 ++-- add_expense_modal.php | 10 ++- add_payment_modal.php | 6 +- add_revenue_modal.php | 139 ++++++++++++++++++++++++++++++++++++ add_transfer_modal.php | 12 +++- dashboard.php | 61 +++++++++++----- edit_expense_modal.php | 15 ++-- edit_revenue_modal.php | 115 ++++++++++++++++++++++++++++++ edit_transfer_modal.php | 40 ++++++----- invoices.php | 2 +- login.php | 8 +++ payments.php | 2 +- post.php | 68 ++++++++++++++---- report_expense_summary.php | 2 +- report_income_summary.php | 21 +++++- report_profit_loss.php | 84 +++++++++++++++++++--- revenues.php | 140 +++++++++++++++++++++++++++++++++++++ setup.php | 5 +- side_nav.php | 6 ++ transfers.php | 8 +-- update_revenues.php | 18 +++++ 23 files changed, 697 insertions(+), 87 deletions(-) create mode 100644 add_revenue_modal.php create mode 100644 edit_revenue_modal.php create mode 100644 revenues.php create mode 100644 update_revenues.php diff --git a/README.md b/README.md index 7263e5e6..22dcb1cd 100644 --- a/README.md +++ b/README.md @@ -45,10 +45,10 @@ CRM, Accounting and Invoicing System for small managed IT companies ### Installation Instructions -* Download the files in this repository +* Clone this repo * Create a Mysql database * Point your browser to setup.php fill in the info -* Your Done! that easy.. +* Your Done! #### Requirements * Webserver (Apache, NGINX) diff --git a/accounts.php b/accounts.php index 6cf1effd..8951caa1 100644 --- a/accounts.php +++ b/accounts.php @@ -84,12 +84,16 @@ $sql_payments = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS total_payments FROM payments WHERE account_id = $account_id"); $row = mysqli_fetch_array($sql_payments); $total_payments = $row['total_payments']; + + $sql_revenues = mysqli_query($mysqli,"SELECT SUM(revenue_amount) AS total_revenues FROM revenues WHERE account_id = $account_id"); + $row = mysqli_fetch_array($sql_revenues); + $total_revenues = $row['total_revenues']; $sql_expenses = mysqli_query($mysqli,"SELECT SUM(expense_amount) AS total_expenses FROM expenses WHERE account_id = $account_id"); $row = mysqli_fetch_array($sql_expenses); $total_expenses = $row['total_expenses']; - $balance = $opening_balance + $total_payments - $total_expenses; + $balance = $opening_balance + $total_payments + $total_revenues - $total_expenses; ?> diff --git a/add_expense_copy_modal.php b/add_expense_copy_modal.php index cd6d9bd2..63437849 100644 --- a/add_expense_copy_modal.php +++ b/add_expense_copy_modal.php @@ -48,18 +48,22 @@ while($row = mysqli_fetch_array($sql_accounts)){ $account_id_select = $row['account_id']; $account_name_select = $row['account_name']; - $opening_balance = $row['opening_balance']; - + $opening_balance = $row['opening_balance']; + $sql_payments = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS total_payments FROM payments WHERE account_id = $account_id_select"); $row = mysqli_fetch_array($sql_payments); $total_payments = $row['total_payments']; + $sql_revenues = mysqli_query($mysqli,"SELECT SUM(revenue_amount) AS total_revenues FROM revenues WHERE account_id = $account_id_select"); + $row = mysqli_fetch_array($sql_revenues); + $total_revenues = $row['total_revenues']; + $sql_expenses = mysqli_query($mysqli,"SELECT SUM(expense_amount) AS total_expenses FROM expenses WHERE account_id = $account_id_select"); $row = mysqli_fetch_array($sql_expenses); $total_expenses = $row['total_expenses']; - $balance = $opening_balance + $total_payments - $total_expenses; - ?> + $balance = $opening_balance + $total_payments + $total_revenues - $total_expenses; + ?> diff --git a/add_payment_modal.php b/add_payment_modal.php index 03513a11..ec1b48fe 100644 --- a/add_payment_modal.php +++ b/add_payment_modal.php @@ -52,11 +52,15 @@ $row = mysqli_fetch_array($sql_payments); $total_payments = $row['total_payments']; + $sql_revenues = mysqli_query($mysqli,"SELECT SUM(revenue_amount) AS total_revenues FROM revenues WHERE account_id = $account_id"); + $row = mysqli_fetch_array($sql_revenues); + $total_revenues = $row['total_revenues']; + $sql_expenses = mysqli_query($mysqli,"SELECT SUM(expense_amount) AS total_expenses FROM expenses WHERE account_id = $account_id"); $row = mysqli_fetch_array($sql_expenses); $total_expenses = $row['total_expenses']; - $balance = $opening_balance + $total_payments - $total_expenses; + $balance = $opening_balance + $total_payments + $total_revenues - $total_expenses; ?> diff --git a/add_revenue_modal.php b/add_revenue_modal.php new file mode 100644 index 00000000..f25945e2 --- /dev/null +++ b/add_revenue_modal.php @@ -0,0 +1,139 @@ + \ No newline at end of file diff --git a/add_transfer_modal.php b/add_transfer_modal.php index 76ea3be5..3389fffe 100644 --- a/add_transfer_modal.php +++ b/add_transfer_modal.php @@ -50,11 +50,15 @@ $row = mysqli_fetch_array($sql_payments); $total_payments = $row['total_payments']; + $sql_revenues = mysqli_query($mysqli,"SELECT SUM(revenue_amount) AS total_revenues FROM revenues WHERE account_id = $account_id"); + $row = mysqli_fetch_array($sql_revenues); + $total_revenues = $row['total_revenues']; + $sql_expenses = mysqli_query($mysqli,"SELECT SUM(expense_amount) AS total_expenses FROM expenses WHERE account_id = $account_id"); $row = mysqli_fetch_array($sql_expenses); $total_expenses = $row['total_expenses']; - $balance = $opening_balance + $total_payments - $total_expenses; + $balance = $opening_balance + $total_payments + $total_revenues - $total_expenses; ?> @@ -83,12 +87,16 @@ $sql_payments = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS total_payments FROM payments WHERE account_id = $account_id"); $row = mysqli_fetch_array($sql_payments); $total_payments = $row['total_payments']; + + $sql_revenues = mysqli_query($mysqli,"SELECT SUM(revenue_amount) AS total_revenues FROM revenues WHERE account_id = $account_id"); + $row = mysqli_fetch_array($sql_revenues); + $total_revenues = $row['total_revenues']; $sql_expenses = mysqli_query($mysqli,"SELECT SUM(expense_amount) AS total_expenses FROM expenses WHERE account_id = $account_id"); $row = mysqli_fetch_array($sql_expenses); $total_expenses = $row['total_expenses']; - $balance = $opening_balance + $total_payments - $total_expenses; + $balance = $opening_balance + $total_payments + $total_revenues - $total_expenses; ?> diff --git a/dashboard.php b/dashboard.php index 53eb1c20..349556e2 100644 --- a/dashboard.php +++ b/dashboard.php @@ -13,14 +13,24 @@ if(isset($_GET['year'])){ $year = date('Y'); } -//GET THE YEARS -$sql_payment_years = mysqli_query($mysqli,"SELECT DISTINCT YEAR(payment_date) AS payment_year FROM payments ORDER BY payment_year DESC"); +//GET unique years from expenses, payments and revenues +$sql_payment_years = mysqli_query($mysqli,"SELECT YEAR(expense_date) AS all_years FROM expenses UNION DISTINCT SELECT YEAR(payment_date) FROM payments UNION DISTINCT SELECT YEAR(revenue_date) FROM revenues ORDER BY all_years DESC"); -//Get Total income Do not grab transfer payment as these have an invoice_id of 0 -$sql_total_income = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS total_income FROM payments WHERE YEAR(payment_date) = $year AND invoice_id > 0"); -$row = mysqli_fetch_array($sql_total_income); -$total_income = $row['total_income']; +//GET unique years from expenses, payments and revenues +$sql_payment_years = mysqli_query($mysqli,"SELECT YEAR(expense_date) AS all_years FROM expenses UNION DISTINCT SELECT YEAR(payment_date) FROM payments UNION DISTINCT SELECT YEAR(revenue_date) FROM revenues ORDER BY all_years DESC"); + + +//Get Total income +$sql_total_payments_to_invoices = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS total_payments_to_invoices FROM payments WHERE YEAR(payment_date) = $year"); +$row = mysqli_fetch_array($sql_total_payments_to_invoices); +$total_payments_to_invoices = $row['total_payments_to_invoices']; +//Do not grab transfer payment as these have an category_id of 0 +$sql_total_revenues = mysqli_query($mysqli,"SELECT SUM(revenue_amount) AS total_revenues FROM revenues WHERE YEAR(revenue_date) = $year AND category_id > 0"); +$row = mysqli_fetch_array($sql_total_revenues); +$total_revenues = $row['total_revenues']; + +$total_income = $total_payments_to_invoices + $total_revenues; //Get Total expenses and do not grab transfer expenses as these have a vendor of 0 $sql_total_expenses = mysqli_query($mysqli,"SELECT SUM(expense_amount) AS total_expenses FROM expenses WHERE vendor_id > 0 AND YEAR(expense_date) = $year"); @@ -32,13 +42,13 @@ $sql_invoice_totals = mysqli_query($mysqli,"SELECT SUM(invoice_amount) AS invoic $row = mysqli_fetch_array($sql_invoice_totals); $invoice_totals = $row['invoice_totals']; -$recievables = $invoice_totals - $total_income; +$recievables = $invoice_totals - $total_payments_to_invoices; $profit = $total_income - $total_expenses; -$sql_accounts = mysqli_query($mysqli,"SELECT * FROM accounts ORDER BY account_id DESC"); +$sql_accounts = mysqli_query($mysqli,"SELECT * FROM accounts"); -$sql_latest_income_payments = mysqli_query($mysqli,"SELECT * FROM payments, invoices, clients +$sql_latest_invoice_payments = mysqli_query($mysqli,"SELECT * FROM payments, invoices, clients WHERE payments.invoice_id = invoices.invoice_id AND invoices.client_id = clients.client_id ORDER BY payment_id DESC LIMIT 5" @@ -57,7 +67,7 @@ $sql_latest_expenses = mysqli_query($mysqli,"SELECT * FROM expenses, vendors, ca @@ -167,18 +177,24 @@ $sql_latest_expenses = mysqli_query($mysqli,"SELECT * FROM expenses, vendors, ca - $
- Latest Payments + Latest Invoice Payments
@@ -207,7 +223,7 @@ $sql_latest_expenses = mysqli_query($mysqli,"SELECT * FROM expenses, vendors, ca 0 AND YEAR(revenue_date) = $year AND MONTH(revenue_date) = $month"); + $row = mysqli_fetch_array($sql_revenues); + $revenues_for_month = $row['revenue_amount_for_month']; + + $income_for_month = $payments_for_month + $revenues_for_month; + if($income_for_month > 0 AND $income_for_month > $largest_income_month){ $largest_income_month = $income_for_month; } diff --git a/edit_expense_modal.php b/edit_expense_modal.php index 9f28a866..c0f51bac 100644 --- a/edit_expense_modal.php +++ b/edit_expense_modal.php @@ -46,21 +46,26 @@ + + + + + + \ No newline at end of file diff --git a/edit_transfer_modal.php b/edit_transfer_modal.php index a407d585..0c74064c 100644 --- a/edit_transfer_modal.php +++ b/edit_transfer_modal.php @@ -11,7 +11,7 @@
+
diff --git a/report_income_summary.php b/report_income_summary.php index 25b3b888..4f488249 100644 --- a/report_income_summary.php +++ b/report_income_summary.php @@ -7,7 +7,7 @@ if(isset($_GET['year'])){ $year = date('Y'); } -$sql_payment_years = mysqli_query($mysqli,"SELECT DISTINCT YEAR(payment_date) AS payment_year FROM payments WHERE invoice_id > 0 ORDER BY payment_year DESC"); +$sql_payment_years = mysqli_query($mysqli,"SELECT DISTINCT YEAR(payment_date) AS payment_year FROM payments 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' ORDER BY category_name ASC"); @@ -35,7 +35,7 @@ $sql_categories = mysqli_query($mysqli,"SELECT * FROM categories WHERE category_
-
Category
+
@@ -67,9 +67,18 @@ $sql_categories = mysqli_query($mysqli,"SELECT * FROM categories WHERE category_ 0 AND YEAR(revenue_date) = $year AND MONTH(revenue_date) = $month"); + $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; ?> diff --git a/report_profit_loss.php b/report_profit_loss.php index b88bab7c..5a3694b4 100644 --- a/report_profit_loss.php +++ b/report_profit_loss.php @@ -8,8 +8,8 @@ if(isset($_GET['year'])){ $year = date('Y'); } -//GET unique years from expenses and payments -$sql_all_years = mysqli_query($mysqli,"SELECT YEAR(expense_date) AS all_years FROM expenses UNION DISTINCT SELECT YEAR(payment_date) FROM payments ORDER BY all_years DESC"); +//GET unique years from expenses, payments and revenues +$sql_all_years = mysqli_query($mysqli,"SELECT YEAR(expense_date) AS all_years FROM expenses UNION DISTINCT SELECT YEAR(payment_date) FROM payments UNION DISTINCT SELECT YEAR(revenue_date) FROM revenues ORDER BY all_years DESC"); $sql_categories_income = mysqli_query($mysqli,"SELECT * FROM categories WHERE category_type = 'Income' ORDER BY category_name ASC"); @@ -40,7 +40,7 @@ $sql_categories_expense = mysqli_query($mysqli,"SELECT * FROM categories WHERE c
-
Category
+
@@ -70,7 +70,15 @@ $sql_categories_expense = mysqli_query($mysqli,"SELECT * FROM categories WHERE c 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_quarter_one = $payment_amount_for_quarter_one + $row['payment_amount_for_month']; + $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; } ?> @@ -82,7 +90,15 @@ $sql_categories_expense = mysqli_query($mysqli,"SELECT * FROM categories WHERE c 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_quarter_two = $payment_amount_for_quarter_two + $row['payment_amount_for_month']; + $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; } ?> @@ -94,7 +110,14 @@ $sql_categories_expense = mysqli_query($mysqli,"SELECT * FROM categories WHERE c 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_quarter_three = $payment_amount_for_quarter_three + $row['payment_amount_for_month']; + $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; } ?> @@ -106,7 +129,14 @@ $sql_categories_expense = mysqli_query($mysqli,"SELECT * FROM categories WHERE c 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_quarter_four = $payment_amount_for_quarter_four + $row['payment_amount_for_month']; + $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; @@ -137,7 +167,15 @@ $sql_categories_expense = mysqli_query($mysqli,"SELECT * FROM categories WHERE c 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"); $row = mysqli_fetch_array($sql_payments); - $payment_total_amount_for_quarter_one = $payment_total_amount_for_quarter_one + $row['payment_total_amount_for_month']; + $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"); + $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; } ?> @@ -149,7 +187,15 @@ $sql_categories_expense = mysqli_query($mysqli,"SELECT * FROM categories WHERE c 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"); $row = mysqli_fetch_array($sql_payments); - $payment_total_amount_for_quarter_two = $payment_total_amount_for_quarter_two + $row['payment_total_amount_for_month']; + $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"); + $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; } ?> @@ -161,7 +207,15 @@ $sql_categories_expense = mysqli_query($mysqli,"SELECT * FROM categories WHERE c 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"); $row = mysqli_fetch_array($sql_payments); - $payment_total_amount_for_quarter_three = $payment_total_amount_for_quarter_three + $row['payment_total_amount_for_month']; + $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"); + $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; } ?> @@ -173,7 +227,15 @@ $sql_categories_expense = mysqli_query($mysqli,"SELECT * FROM categories WHERE c 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"); $row = mysqli_fetch_array($sql_payments); - $payment_total_amount_for_quarter_four = $payment_total_amount_for_quarter_four + $row['payment_total_amount_for_month']; + $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"); + $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; diff --git a/revenues.php b/revenues.php new file mode 100644 index 00000000..20da0854 --- /dev/null +++ b/revenues.php @@ -0,0 +1,140 @@ + $sb, 'o' => $o))); + + if(isset($_GET['p'])){ + $p = intval($_GET['p']); + $record_from = (($p)-1)*10; + $record_to = 10; + }else{ + $record_from = 0; + $record_to = 10; + $p = 1; + } + + if(isset($_GET['q'])){ + $q = $_GET['q']; + }else{ + $q = ""; + } + + if(!empty($_GET['sb'])){ + $sb = $_GET['sb']; + }else{ + $sb = "revenue_id"; + } + + if(isset($_GET['o'])){ + if($_GET['o'] == 'ASC'){ + $o = "ASC"; + $disp = "DESC"; + }else{ + $o = "DESC"; + $disp = "ASC"; + } + }else{ + $o = "DESC"; + $disp = "ASC"; + } + + $sql = mysqli_query($mysqli,"SELECT SQL_CALC_FOUND_ROWS * FROM accounts, revenues, categories + WHERE revenues.account_id = accounts.account_id + AND revenues.category_id = categories.category_id + AND (account_name LIKE '%$q%' AND revenue_payment_method LIKE '%$q%') + ORDER BY $sb $o LIMIT $record_from, $record_to"); + + $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()")); + $total_found_rows = $num_rows[0]; + $total_pages = ceil($total_found_rows / 10); + +?> + +
+
+
Revenues
+ +
+
+
+
+ +
+ +
+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
DateCategoryAmountAccountMethodReference
$ + + +
+ + + +
+
+ + + + + - + diff --git a/side_nav.php b/side_nav.php index ff2b7aab..e631cfb9 100644 --- a/side_nav.php +++ b/side_nav.php @@ -42,6 +42,12 @@ Quotes +