From 07e09e1948ff3eb965077bbdbbe093a31d87f724 Mon Sep 17 00:00:00 2001 From: jekkos Date: Sat, 11 May 2024 23:37:08 +0200 Subject: [PATCH] Fix register functionality Fix controller method names --- app/Config/Routes.php | 14 ----------- app/Controllers/Items.php | 2 +- app/Controllers/Receivings.php | 18 +++++++-------- app/Controllers/Sales.php | 36 ++++++++++++++--------------- app/Views/items/form_inventory.php | 2 +- app/Views/partial/print_receipt.php | 2 +- app/Views/receivings/receiving.php | 14 +++++------ app/Views/sales/form.php | 4 ++-- app/Views/sales/invoice.php | 2 +- app/Views/sales/quote.php | 4 ++-- app/Views/sales/receipt.php | 2 +- app/Views/sales/register.php | 20 ++++++++-------- app/Views/sales/tax_invoice.php | 2 +- app/Views/sales/work_order.php | 2 +- 14 files changed, 55 insertions(+), 69 deletions(-) diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 88e7a1eda..b4fbf3221 100644 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -14,20 +14,6 @@ $routes->post('login', 'Login::index'); $routes->add('no_access/index/(:segment)', 'No_access::index/$1'); $routes->add('no_access/index/(:segment)/(:segment)', 'No_access::index/$1/$2'); -$routes->add('sales/index/(:any)', 'Sales::manage/$1'); -$routes->add('sales/index/(:any)/(:any)', 'Sales::manage/$1/$2'); -$routes->add('sales/index/(:any)/(:any)/(:any)', 'Sales::manage/$1/$2/$3'); - -$routes->add('sales/receipt/(:num)', 'Sales::receipt/$1'); -$routes->add('sales/invoice/(:num)', 'Sales::invoice/$1'); -$routes->add('sales/edit/(:num)', 'Sales::edit/$1'); -$routes->add('sales/sales_keyboard_help', 'Sales::sales_keyboard_help'); - -$routes->add('items/save_inventory/(:num)', 'Items::save_inventory/$1'); - -$routes->add('receivings/edit/(:num)', 'Receivings::edit/$1'); -$routes->add('receivings/receipt/(:num)', 'Receivings::receipt/$1'); - $routes->add('reports/summary_(:any)/(:any)/(:any)', 'Reports::Summary_$1/$2/$3/$4'); $routes->add('reports/summary_expenses_categories', 'Reports::date_input_only'); $routes->add('reports/summary_payments', 'Reports::date_input_only'); diff --git a/app/Controllers/Items.php b/app/Controllers/Items.php index 5b17c894a..5221c839f 100644 --- a/app/Controllers/Items.php +++ b/app/Controllers/Items.php @@ -897,7 +897,7 @@ class Items extends Secure_Controller * @throws ReflectionException * @noinspection PhpUnused */ - public function save_inventory($item_id = NEW_ENTRY): void + public function postSaveInventory($item_id = NEW_ENTRY): void { $employee_id = $this->employee->get_logged_in_employee_info()->person_id; $cur_item_info = $this->item->get_info($item_id); diff --git a/app/Controllers/Receivings.php b/app/Controllers/Receivings.php index 8c58c5e5a..b32fad58d 100644 --- a/app/Controllers/Receivings.php +++ b/app/Controllers/Receivings.php @@ -80,7 +80,7 @@ class Receivings extends Secure_Controller * Called in the view. * @return void */ - public function postSelect_supplier(): void + public function postSelectSupplier(): void { $supplier_id = $this->request->getPost('supplier', FILTER_SANITIZE_NUMBER_INT); if($this->supplier->exists($supplier_id)) @@ -118,7 +118,7 @@ class Receivings extends Secure_Controller /** * @return void */ - public function set_comment(): void + public function postSetComment(): void { $this->receiving_lib->set_comment($this->request->getPost('comment', FILTER_SANITIZE_FULL_SPECIAL_CHARS)); } @@ -127,7 +127,7 @@ class Receivings extends Secure_Controller * Called in the view. * @return void */ - public function set_print_after_sale(): void + public function postSetPrintAfterSale(): void { $this->receiving_lib->set_print_after_sale($this->request->getPost('recv_print_after_sale') != null); } @@ -135,7 +135,7 @@ class Receivings extends Secure_Controller /** * @return void */ - public function set_reference(): void + public function postSetReference(): void { $this->receiving_lib->set_reference($this->request->getPost('recv_reference', FILTER_SANITIZE_FULL_SPECIAL_CHARS)); } @@ -219,7 +219,7 @@ class Receivings extends Secure_Controller * @param $receiving_id * @return void */ - public function edit($receiving_id): void + public function getEdit($receiving_id): void { $data = []; @@ -281,7 +281,7 @@ class Receivings extends Secure_Controller * Called in the view. * @return void */ - public function remove_supplier(): void + public function getRemoveSupplier(): void { $this->receiving_lib->clear_reference(); $this->receiving_lib->remove_supplier(); @@ -359,7 +359,7 @@ class Receivings extends Secure_Controller * * @throws ReflectionException */ - public function requisition_complete(): void + public function postRequisitionComplete(): void { if($this->receiving_lib->get_stock_source() != $this->receiving_lib->get_stock_destination()) { @@ -384,7 +384,7 @@ class Receivings extends Secure_Controller * @param $receiving_id * @return void */ - public function receipt($receiving_id): void + public function getReceipt($receiving_id): void { $receiving_info = $this->receiving->get_info($receiving_id)->getRowArray(); $this->receiving_lib->copy_entire_receiving($receiving_id); @@ -516,7 +516,7 @@ class Receivings extends Secure_Controller * Called in the view. * @return void */ - public function cancel_receiving(): void + public function postCancelReceiving(): void { $this->receiving_lib->clear_all(); diff --git a/app/Controllers/Sales.php b/app/Controllers/Sales.php index d82c7a882..b241b38eb 100644 --- a/app/Controllers/Sales.php +++ b/app/Controllers/Sales.php @@ -194,7 +194,7 @@ class Sales extends Secure_Controller /** * @return void */ - public function postSelect_customer(): void + public function postSelectCustomer(): void { $customer_id = (int)$this->request->getPost('customer', FILTER_SANITIZE_NUMBER_INT); if($this->customer->exists($customer_id)) @@ -298,7 +298,7 @@ class Sales extends Secure_Controller /** * @return void */ - public function set_comment(): void + public function postSetComment(): void { $this->sale_lib->set_comment($this->request->getPost('comment', FILTER_SANITIZE_FULL_SPECIAL_CHARS)); } @@ -307,7 +307,7 @@ class Sales extends Secure_Controller * Called in the view. * @return void */ - public function set_invoice_number(): void + public function postSetInvoiceNumber(): void { $this->sale_lib->set_invoice_number($this->request->getPost('sales_invoice_number', FILTER_SANITIZE_NUMBER_INT)); } @@ -315,7 +315,7 @@ class Sales extends Secure_Controller /** * @return void */ - public function set_payment_type(): void //TODO: This function does not appear to be called anywhere in the code. + public function postSetPaymentType(): void //TODO: This function does not appear to be called anywhere in the code. { $this->sale_lib->set_payment_type($this->request->getPost('selected_payment_type', FILTER_SANITIZE_FULL_SPECIAL_CHARS)); $this->_reload(); //TODO: Hungarian notation. @@ -325,7 +325,7 @@ class Sales extends Secure_Controller * Called in the view. * @return void */ - public function set_print_after_sale(): void + public function postSetPrintAfterSale(): void { $this->sale_lib->set_print_after_sale($this->request->getPost('sales_print_after_sale') != null); } @@ -333,7 +333,7 @@ class Sales extends Secure_Controller /** * @return void */ - public function set_price_work_orders(): void + public function postSetPriceWorkOrders(): void { $price_work_orders = prepare_decimal($this->request->getPost('price_work_orders')); $this->sale_lib->set_price_work_orders(filter_var($price_work_orders, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION)); @@ -343,7 +343,7 @@ class Sales extends Secure_Controller * Called in the view. * @return void */ - public function set_email_receipt(): void + public function postSetEmailReceipt(): void { $this->sale_lib->set_email_receipt($this->request->getPost('email_receipt', FILTER_SANITIZE_FULL_SPECIAL_CHARS)); } @@ -925,7 +925,7 @@ class Sales extends Secure_Controller * @param string $type * @return bool */ - public function send_pdf(int $sale_id, string $type = 'invoice'): bool + public function getSendPdf(int $sale_id, string $type = 'invoice'): bool { $sale_data = $this->_load_sale_data($sale_id); @@ -973,7 +973,7 @@ class Sales extends Secure_Controller * @param int $sale_id * @return bool */ - public function send_receipt(int $sale_id): bool + public function getSendReceipt(int $sale_id): bool { $sale_data = $this->_load_sale_data($sale_id); @@ -1325,7 +1325,7 @@ class Sales extends Secure_Controller * @param int $sale_id * @return void */ - public function receipt(int $sale_id): void + public function getReceipt(int $sale_id): void { $data = $this->_load_sale_data($sale_id); echo view('sales/receipt', $data); @@ -1336,7 +1336,7 @@ class Sales extends Secure_Controller * @param int $sale_id * @return void */ - public function invoice(int $sale_id): void + public function getInvoice(int $sale_id): void { $data = $this->_load_sale_data($sale_id); @@ -1348,7 +1348,7 @@ class Sales extends Secure_Controller * @param int $sale_id * @return void */ - public function edit(int $sale_id): void + public function getEdit(int $sale_id): void { $data = []; @@ -1614,7 +1614,7 @@ class Sales extends Secure_Controller /** * @return void */ - public function discard_suspended_sale(): void + public function discardSuspendedSale(): void { $suspended_id = $this->sale_lib->get_suspended_id(); $this->sale_lib->clear_all(); @@ -1700,7 +1700,7 @@ class Sales extends Secure_Controller /** * @return void */ - public function sales_keyboard_help() : void + public function getSalesKeyboardHelp() : void { echo view('sales/help'); } @@ -1708,7 +1708,7 @@ class Sales extends Secure_Controller /** * @return void */ - public function check_invoice_number(): void + public function postCheckInvoiceNumber(): void { $sale_id = $this->request->getPost('sale_id', FILTER_SANITIZE_NUMBER_INT); $invoice_number = $this->request->getPost('invoice_number', FILTER_SANITIZE_FULL_SPECIAL_CHARS); @@ -1742,7 +1742,7 @@ class Sales extends Secure_Controller /** * @return void */ - public function change_item_number(): void + public function postChangeItemNumber(): void { $item_id = $this->request->getPost('item_id', FILTER_SANITIZE_NUMBER_INT); $item_number = $this->request->getPost('item_number', FILTER_SANITIZE_FULL_SPECIAL_CHARS); @@ -1759,7 +1759,7 @@ class Sales extends Secure_Controller /** * @return void */ - public function change_item_name(): void + public function postChangeItemName(): void { $item_id = $this->request->getPost('item_id', FILTER_SANITIZE_NUMBER_INT); $name = $this->request->getPost('item_name', FILTER_SANITIZE_FULL_SPECIAL_CHARS); @@ -1780,7 +1780,7 @@ class Sales extends Secure_Controller /** * @return void */ - public function change_item_description(): void + public function postChangeItemDescription(): void { $item_id = $this->request->getPost('item_id', FILTER_SANITIZE_NUMBER_INT); $description = $this->request->getPost('item_description', FILTER_SANITIZE_FULL_SPECIAL_CHARS); diff --git a/app/Views/items/form_inventory.php b/app/Views/items/form_inventory.php index 77a8562bd..be002d007 100644 --- a/app/Views/items/form_inventory.php +++ b/app/Views/items/form_inventory.php @@ -10,7 +10,7 @@ -item_id", ['id' => 'item_form', 'class' => 'form-horizontal']) ?> +item_id", ['id' => 'item_form', 'class' => 'form-horizontal']) ?>
'control-label col-xs-3']) ?> diff --git a/app/Views/partial/print_receipt.php b/app/Views/partial/print_receipt.php index 093d3af8a..4011e4caa 100644 --- a/app/Views/partial/print_receipt.php +++ b/app/Views/partial/print_receipt.php @@ -82,7 +82,7 @@ if($print_after_sale) setTimeout(function () { window.location.href = ""; }, ); - }); + }));  ' . lang('Common.remove').' '.lang('Suppliers.supplier'), [ 'class' => 'btn btn-danger btn-sm', @@ -333,7 +333,7 @@ if (isset($success)) else { ?> - 'select_supplier_form', 'class' => 'form-horizontal']) ?> + 'select_supplier_form', 'class' => 'form-horizontal']) ?>
- 'finish_receiving_form', 'class' => 'form-horizontal']) ?> + 'finish_receiving_form', 'class' => 'form-horizontal']) ?>
', {comment: $('#comment').val()}); + $.post('', {comment: $('#comment').val()}); }); $('#recv_reference').keyup(function() { - $.post('', {recv_reference: $('#recv_reference').val()}); + $.post('', {recv_reference: $('#recv_reference').val()}); }); $("#recv_print_after_sale").change(function() { - $.post('', {recv_print_after_sale: $(this).is(":checked")}); + $.post('', {recv_print_after_sale: $(this).is(":checked")}); }); $('#item,#supplier').click(function() @@ -569,7 +569,7 @@ $(document).ready(function() { if (confirm('')) { - $('#finish_receiving_form').attr('action', ''); + $('#finish_receiving_form').attr('action', ''); $('#finish_receiving_form').submit(); } }); diff --git a/app/Views/sales/form.php b/app/Views/sales/form.php index cd0e09fbb..65fd24eb1 100644 --- a/app/Views/sales/form.php +++ b/app/Views/sales/form.php @@ -166,7 +166,7 @@ $(document).ready(function() $('#send_invoice').click(function(event) { if (confirm("")) { - $.get("", + $.get("", function(response) { BootstrapDialog.closeAll(); $.notify( { message: response.message }, { type: response.success ? 'success' : 'danger'} ) @@ -245,7 +245,7 @@ $(document).ready(function() { remote: { - url: "", + url: "", type: 'POST', data: { 'sale_id': , diff --git a/app/Views/sales/invoice.php b/app/Views/sales/invoice.php index 78bd52383..d0dcc7724 100644 --- a/app/Views/sales/invoice.php +++ b/app/Views/sales/invoice.php @@ -35,7 +35,7 @@ $(document).ready(function() { var send_email = function() { - $.get('', + $.get('', function(response) { $.notify({ message: response.message }, { type: response.success ? 'success' : 'danger'}); diff --git a/app/Views/sales/quote.php b/app/Views/sales/quote.php index f54b5dc0d..a06bf49fa 100644 --- a/app/Views/sales/quote.php +++ b/app/Views/sales/quote.php @@ -31,7 +31,7 @@ if (isset($error_message)) { var send_email = function() { - $.get('', + $.get('', function(response) { $.notify( { message: response.message }, { type: response.success ? 'success' : 'danger'} ) @@ -57,7 +57,7 @@ if (isset($error_message))
 ' . lang('Sales.send_quote') ?>
 ' . lang('Sales.register'), ['class' => 'btn btn-info btn-sm', 'id' => 'show_sales_button']) ?> -  ' . lang('Sales.discard'), ['class' => 'btn btn-danger btn-sm', 'id' => 'discard_quote_button']) ?> +  ' . lang('Sales.discard'), ['class' => 'btn btn-danger btn-sm', 'id' => 'discard_quote_button']) ?>
diff --git a/app/Views/sales/receipt.php b/app/Views/sales/receipt.php index 5742a2b31..cf3d019cc 100644 --- a/app/Views/sales/receipt.php +++ b/app/Views/sales/receipt.php @@ -24,7 +24,7 @@ if (isset($error_message)) { var send_email = function() { - $.get('', + $.get('', function(response) { $.notify( { message: response.message }, { type: response.success ? 'success' : 'danger'} ) diff --git a/app/Views/sales/register.php b/app/Views/sales/register.php index 0ae22721b..70932db3f 100644 --- a/app/Views/sales/register.php +++ b/app/Views/sales/register.php @@ -345,7 +345,7 @@ if(isset($success))
- 'select_customer_form', 'class' => 'form-horizontal']) ?> + 'select_customer_form', 'class' => 'form-horizontal']) ?> ">   - @@ -737,7 +737,7 @@ $(document).ready(function() var item_id = $(this).parents('tr').find("input[name='item_id']").val(); var item_number = $(this).val(); $.ajax({ - url: "", + url: "", method: 'post', data: { 'item_id': item_id, @@ -751,7 +751,7 @@ $(document).ready(function() var item_id = $(this).parents('tr').find("input[name='item_id']").val(); var item_name = $(this).val(); $.ajax({ - url: "", + url: "", method: 'post', data: { 'item_id': item_id, @@ -765,7 +765,7 @@ $(document).ready(function() var item_id = $(this).parents('tr').find("input[name='item_id']").val(); var item_description = $(this).val(); $.ajax({ - url: "", + url: "", method: 'post', data: { 'item_id': item_id, @@ -845,7 +845,7 @@ $(document).ready(function() }); $('#comment').keyup(function() { - $.post("", {comment: $('#comment').val()}); + $.post("", {comment: $('#comment').val()}); }); $('#sales_invoice_number').keyup(function() { - $.post("", {sales_invoice_number: $('#sales_invoice_number').val()}); + $.post("", {sales_invoice_number: $('#sales_invoice_number').val()}); }); $('#sales_print_after_sale').change(function() { - $.post("", {sales_print_after_sale: $(this).is(':checked')}); + $.post("", {sales_print_after_sale: $(this).is(':checked')}); }); $('#price_work_orders').change(function() { - $.post("", {price_work_orders: $(this).is(':checked')}); + $.post("", {price_work_orders: $(this).is(':checked')}); }); $('#email_receipt').change(function() { - $.post("", {email_receipt: $(this).is(':checked')}); + $.post("", {email_receipt: $(this).is(':checked')}); }); $('#finish_sale_button').click(function() { diff --git a/app/Views/sales/tax_invoice.php b/app/Views/sales/tax_invoice.php index 85e5a6c7e..e8b9516b4 100644 --- a/app/Views/sales/tax_invoice.php +++ b/app/Views/sales/tax_invoice.php @@ -35,7 +35,7 @@ $(document).ready(function() { var send_email = function() { - $.get('', + $.get('', function(response) { $.notify( { message: response.message }, { type: response.success ? 'success' : 'danger'} ) diff --git a/app/Views/sales/work_order.php b/app/Views/sales/work_order.php index 23a551696..78da9a7e4 100644 --- a/app/Views/sales/work_order.php +++ b/app/Views/sales/work_order.php @@ -33,7 +33,7 @@ if(isset($error_message)) { var send_email = function() { - $.get('', + $.get('', function(response) { $.notify( { message: response.message }, { type: response.success ? 'success' : 'danger'} )