From 2d45ca626ba8f23fae47242d1421e29a9ede8a3a Mon Sep 17 00:00:00 2001 From: jekkos Date: Sun, 13 Nov 2022 00:59:23 +0100 Subject: [PATCH] Apply changes from master --- app/Helpers/locale_helper.php | 1 + app/Language/tl-PH/reports_lang.php | 2 +- app/Libraries/Token_lib.php | 12 ++++++------ app/Models/Reports/Summary_taxes.php | 4 +++- app/Views/configs/info_config.php | 2 +- app/Views/expenses/manage.php | 1 + app/Views/login.php | 4 ++-- app/Views/partial/header_js.php | 17 ++++++++++++++++- app/Views/reports/tabular.php | 3 ++- app/Views/reports/tabular_details.php | 1 + app/Views/sales/manage.php | 16 +++++++++++----- 11 files changed, 45 insertions(+), 18 deletions(-) diff --git a/app/Helpers/locale_helper.php b/app/Helpers/locale_helper.php index fc3ef6b8d..81c4ade51 100644 --- a/app/Helpers/locale_helper.php +++ b/app/Helpers/locale_helper.php @@ -186,6 +186,7 @@ function get_timezones(): array 'Asia/Kabul' => '(GMT+04:30) Kabul', 'Asia/Baku' => '(GMT+04:00) Baku', 'Asia/Yekaterinburg' => '(GMT+05:00) Ekaterinburg', + 'Asia/Karachi' => '(GMT+05:00) Karachi, Islamabad', 'Asia/Tashkent' => '(GMT+05:00) Tashkent', 'Asia/Kolkata' => '(GMT+05:30) Chennai, Kolkata, Mumbai, New Delhi', 'Asia/Katmandu' => '(GMT+05:45) Kathmandu', diff --git a/app/Language/tl-PH/reports_lang.php b/app/Language/tl-PH/reports_lang.php index 97358bfdb..b7c99bb86 100644 --- a/app/Language/tl-PH/reports_lang.php +++ b/app/Language/tl-PH/reports_lang.php @@ -122,7 +122,7 @@ $lang["reports_suppliers"] = "Suppliers"; $lang["reports_suppliers_summary_report"] = "Suppliers Summary Report"; $lang["reports_tax"] = "Tax"; $lang["reports_tax_category"] = "Tax Category"; -$lang["reports_tax_name"] = ""; +$lang["reports_tax_name"] = "Tax Name"; $lang["reports_tax_percent"] = "Tax Percent"; $lang["reports_tax_rate"] = "Tax Rate"; $lang["reports_taxes"] = "Taxes"; diff --git a/app/Libraries/Token_lib.php b/app/Libraries/Token_lib.php index c7cb5bf67..fc7863ef4 100644 --- a/app/Libraries/Token_lib.php +++ b/app/Libraries/Token_lib.php @@ -14,7 +14,7 @@ class Token_lib /** * Expands all the tokens found in a given text string and returns the results. */ - public function render(string $tokened_text, array $tokens = []): string + public function render(string $tokened_text, array $tokens = [], $save TRUE): string { // Apply the transformation for the "%" tokens if any are used if(strpos($tokened_text, '%') !== FALSE) @@ -39,7 +39,7 @@ class Token_lib $token_values = []; $tokens_to_replace = []; - $this->generate($token_tree, $tokens_to_replace, $token_values, $tokens); + $this->generate($token_tree, $tokens_to_replace, $token_values, $tokens, $save); return str_replace($tokens_to_replace, $token_values, $tokened_text); } @@ -128,12 +128,12 @@ class Token_lib return $results; } - public function generate(array $used_tokens, array &$tokens_to_replace, array &$token_values, array $tokens): array //TODO: $tokens + public function generate(array $used_tokens, array &$tokens_to_replace, array &$token_values, array $tokens, $save = TRUE): array //TODO: $tokens { foreach($used_tokens as $token_code => $token_info) { // Generate value here based on the key value - $token_value = $this->resolve_token($token_code); + $token_value = $this->resolve_token($token_code, array(), $save); foreach($token_info as $length => $token_spec) { @@ -152,13 +152,13 @@ class Token_lib return $token_values; } - private function resolve_token($token_code, array $tokens = []): string + private function resolve_token($token_code, array $tokens = [], $save = TRUE): string { foreach(array_merge($tokens, Token::get_tokens()) as $token) { if($token->token_id() == $token_code) { - return $token->get_value(); + return $token->get_value($save); } } diff --git a/app/Models/Reports/Summary_taxes.php b/app/Models/Reports/Summary_taxes.php index 1cbb4d0d6..f39a6389d 100644 --- a/app/Models/Reports/Summary_taxes.php +++ b/app/Models/Reports/Summary_taxes.php @@ -7,6 +7,7 @@ class Summary_taxes extends Summary_report protected function _get_data_columns(): array //TODO: hungarian notation { return [ + ['tax_name' => $this->lang->line('reports_tax_name'), 'sortable' => FALSE], ['tax_percent' => lang('Reports.tax_percent'), 'sorter' => 'number_sorter'], ['report_count' => lang('Reports.sales')], ['subtotal' => lang('Reports.subtotal'), 'sorter' => 'number_sorter'], @@ -64,9 +65,10 @@ class Summary_taxes extends Summary_report . ' ELSE sales_items.quantity_purchased * (sales_items.item_unit_price - sales_items.discount) END)'; } - $query = $this->db->query("SELECT percent, COUNT(DISTINCT sale_id) AS count, ROUND(SUM(subtotal), $decimals) AS subtotal, ROUND(SUM(tax), $decimals) AS tax, ROUND(SUM(total), $decimals) AS total + $query = $this->db->query("SELECT name as name, percent, COUNT(DISTINCT sale_id) AS count, ROUND(SUM(subtotal), $decimals) AS subtotal, ROUND(SUM(tax), $decimals) AS tax, ROUND(SUM(total), $decimals) AS total FROM ( SELECT + name AS name, CONCAT(IFNULL(ROUND(percent, $decimals), 0), '%') AS percent, sales.sale_id AS sale_id, $sale_subtotal AS subtotal, diff --git a/app/Views/configs/info_config.php b/app/Views/configs/info_config.php index 1b4b8faac..51641ce29 100644 --- a/app/Views/configs/info_config.php +++ b/app/Views/configs/info_config.php @@ -147,7 +147,7 @@ $(document).ready(function() { $("a.fileinput-exists").click(function() { $.ajax({ - type: 'GET', + type: 'POST', url: '', dataType: 'json' }) diff --git a/app/Views/expenses/manage.php b/app/Views/expenses/manage.php index 71f76610f..cf56f5317 100644 --- a/app/Views/expenses/manage.php +++ b/app/Views/expenses/manage.php @@ -33,6 +33,7 @@ $(document).ready(function() if($("#table tbody tr").length > 1) { $("#payment_summary").html(response.payment_summary); $("#table tbody tr:last td:first").html(""); + $("#table tbody tr:last").css('font-weight', 'bold'); } }, queryParams: function() { diff --git a/app/Views/login.php b/app/Views/login.php index 46431918e..ab69faba4 100644 --- a/app/Views/login.php +++ b/app/Views/login.php @@ -65,7 +65,7 @@ - + >
@@ -74,7 +74,7 @@ - + " aria-describedby="input-password">
gcaptcha_enable) { diff --git a/app/Views/partial/header_js.php b/app/Views/partial/header_js.php index 8af0a4a4d..8517db98c 100644 --- a/app/Views/partial/header_js.php +++ b/app/Views/partial/header_js.php @@ -47,8 +47,23 @@ return ajax.apply(this, arguments); }; - + $(document).ajaxComplete(setup_csrf_token); + $(document).ready(function(){ + $("#logout").click(function(event) { + event.preventDefault(); + $.ajax({ + url: "", + data: { + "security->get_csrf_token_name(); ?>": csrf_token() + }, + success: function() { + window.location.href = ''; + }, + method: "POST" + }); + }); + }); var submit = $.fn.submit; diff --git a/app/Views/reports/tabular.php b/app/Views/reports/tabular.php index babe54c4f..76edc1220 100644 --- a/app/Views/reports/tabular.php +++ b/app/Views/reports/tabular.php @@ -64,7 +64,8 @@ data: , iconSize: 'sm', paginationVAlign: 'bottom', - escape: false + escape: false, + search: true }); diff --git a/app/Views/reports/tabular_details.php b/app/Views/reports/tabular_details.php index ada4c24ed..1d1949965 100644 --- a/app/Views/reports/tabular_details.php +++ b/app/Views/reports/tabular_details.php @@ -76,6 +76,7 @@ paginationVAlign: 'bottom', detailView: true, escape: false, + search: true, onPageChange: init_dialog, onPostBody: function() { dialog_support.init("a.modal-dlg"); diff --git a/app/Views/sales/manage.php b/app/Views/sales/manage.php index 978184ba1..6af471431 100644 --- a/app/Views/sales/manage.php +++ b/app/Views/sales/manage.php @@ -24,6 +24,15 @@ $(document).ready(function() + table_support.query_params = function() + { + return { + start_date: start_date, + end_date: end_date, + filters: $("#filters").val() || [""] + } + }; + table_support.init({ resource: '', headers: , @@ -33,14 +42,11 @@ $(document).ready(function() if($("#table tbody tr").length > 1) { $("#payment_summary").html(response.payment_summary); $("#table tbody tr:last td:first").html(""); + $("#table tbody tr:last").css('font-weight', 'bold'); } }, queryParams: function() { - return $.extend(arguments[0], { - start_date: start_date, - end_date: end_date, - filters: $("#filters").val() || [""] - }); + return $.extend(arguments[0], table_support.query_params()); }, columns: { 'invoice': {