Skip to content

Commit

Permalink
Fix register functionality
Browse files Browse the repository at this point in the history
Fix controller method names
  • Loading branch information
jekkos committed May 11, 2024
1 parent 9b24231 commit 1296e28
Show file tree
Hide file tree
Showing 14 changed files with 55 additions and 69 deletions.
14 changes: 0 additions & 14 deletions app/Config/Routes.php
Expand Up @@ -14,20 +14,6 @@
$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');
Expand Down
2 changes: 1 addition & 1 deletion app/Controllers/Items.php
Expand Up @@ -897,7 +897,7 @@ public function getRemoveLogo($item_id): void
* @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);
Expand Down
18 changes: 9 additions & 9 deletions app/Controllers/Receivings.php
Expand Up @@ -80,7 +80,7 @@ public function getStockItemSearch(): void
* 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))
Expand Down Expand Up @@ -118,7 +118,7 @@ public function postChangeMode(): void
/**
* @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));
}
Expand All @@ -127,15 +127,15 @@ public function set_comment(): void
* 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);
}

/**
* @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));
}
Expand Down Expand Up @@ -219,7 +219,7 @@ public function postEditItem($item_id): void
* @param $receiving_id
* @return void
*/
public function edit($receiving_id): void
public function getEdit($receiving_id): void
{
$data = [];

Expand Down Expand Up @@ -281,7 +281,7 @@ public function postDelete(int $receiving_id = -1, bool $update_inventory = true
* 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();
Expand Down Expand Up @@ -359,7 +359,7 @@ public function postComplete(): void
*
* @throws ReflectionException
*/
public function requisition_complete(): void
public function postRequisitionComplete(): void
{
if($this->receiving_lib->get_stock_source() != $this->receiving_lib->get_stock_destination())
{
Expand All @@ -384,7 +384,7 @@ public function requisition_complete(): void
* @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);
Expand Down Expand Up @@ -516,7 +516,7 @@ public function save(int $receiving_id = -1): void //TODO: Replace -1 with a con
* Called in the view.
* @return void
*/
public function cancel_receiving(): void
public function postCancelReceiving(): void
{
$this->receiving_lib->clear_all();

Expand Down
36 changes: 18 additions & 18 deletions app/Controllers/Sales.php
Expand Up @@ -194,7 +194,7 @@ public function suggest_search(): void
/**
* @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))
Expand Down Expand Up @@ -298,7 +298,7 @@ public function change_register_mode(int $sale_type): void
/**
* @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));
}
Expand All @@ -307,15 +307,15 @@ public function set_comment(): void
* 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));
}

/**
* @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.
Expand All @@ -325,15 +325,15 @@ public function set_payment_type(): void //TODO: This function does not appear t
* 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);
}

/**
* @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));
Expand All @@ -343,7 +343,7 @@ public function set_price_work_orders(): void
* 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));
}
Expand Down Expand Up @@ -925,7 +925,7 @@ public function postComplete(): void //TODO: this function is huge. Probably sh
* @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);

Expand Down Expand Up @@ -973,7 +973,7 @@ public function send_pdf(int $sale_id, string $type = 'invoice'): bool
* @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);

Expand Down Expand Up @@ -1325,7 +1325,7 @@ private function _reload(array $data = []): void //TODO: Hungarian notation
* @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);
Expand All @@ -1336,7 +1336,7 @@ public function receipt(int $sale_id): void
* @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);

Expand All @@ -1348,7 +1348,7 @@ public function invoice(int $sale_id): void
* @param int $sale_id
* @return void
*/
public function edit(int $sale_id): void
public function getEdit(int $sale_id): void
{
$data = [];

Expand Down Expand Up @@ -1614,7 +1614,7 @@ public function postCancel(): void
/**
* @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();
Expand Down Expand Up @@ -1700,15 +1700,15 @@ public function postUnsuspend(): void
/**
* @return void
*/
public function sales_keyboard_help() : void
public function getSalesKeyboardHelp() : void
{
echo view('sales/help');
}

/**
* @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);
Expand Down Expand Up @@ -1742,7 +1742,7 @@ public function get_filtered(array $cart): array
/**
* @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);
Expand All @@ -1759,7 +1759,7 @@ public function change_item_number(): void
/**
* @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);
Expand All @@ -1780,7 +1780,7 @@ public function change_item_name(): void
/**
* @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);
Expand Down
2 changes: 1 addition & 1 deletion app/Views/items/form_inventory.php
Expand Up @@ -10,7 +10,7 @@

<ul id="error_message_box" class="error_message_box"></ul>

<?= form_open("items/save_inventory/$item_info->item_id", ['id' => 'item_form', 'class' => 'form-horizontal']) ?>
<?= form_open("items/saveInventory/$item_info->item_id", ['id' => 'item_form', 'class' => 'form-horizontal']) ?>
<fieldset id="inv_item_basic_info">
<div class="form-group form-group-sm">
<?= form_label(lang('Items.item_number'), 'name', ['class' => 'control-label col-xs-3']) ?>
Expand Down
2 changes: 1 addition & 1 deletion app/Views/partial/print_receipt.php
Expand Up @@ -82,7 +82,7 @@ function printdoc()
setTimeout(function () {
window.location.href = "<?= site_url('sales') ?>";
}, <?= $config['print_delay_autoreturn'] * 1000 ?>);
});
}));

<?php
}
Expand Down
14 changes: 7 additions & 7 deletions app/Views/receivings/receiving.php
Expand Up @@ -321,7 +321,7 @@
</table>

<?= anchor(
"$controller_name/remove_supplier",
"$controller_name/removeSupplier",
'<span class="glyphicon glyphicon-remove">&nbsp</span>' . lang('Common.remove').' '.lang('Suppliers.supplier'),
[
'class' => 'btn btn-danger btn-sm',
Expand All @@ -333,7 +333,7 @@
else
{
?>
<?= form_open("$controller_name/select_supplier", ['id' => 'select_supplier_form', 'class' => 'form-horizontal']) ?>
<?= form_open("$controller_name/selectSupplier", ['id' => 'select_supplier_form', 'class' => 'form-horizontal']) ?>
<div class="form-group" id="select_customer">
<label id="supplier_label" for="supplier" class="control-label" style="margin-bottom: 1em; margin-top: -1em;"><?= lang(ucfirst($controller_name) .'.select_supplier') ?></label>
<?= form_input ([
Expand Down Expand Up @@ -384,7 +384,7 @@
if($mode == 'requisition')
{
?>
<?= form_open("$controller_name/requisition_complete", ['id' => 'finish_receiving_form', 'class' => 'form-horizontal']) ?>
<?= form_open("$controller_name/requisitionComplete", ['id' => 'finish_receiving_form', 'class' => 'form-horizontal']) ?>
<div class="form-group form-group-sm">
<label id="comment_label" for="comment"><?= lang('Common.comments') ?></label>
<?= form_textarea ([
Expand Down Expand Up @@ -524,17 +524,17 @@

$('#comment').keyup(function()
{
$.post('<?= esc("$controller_name/set_comment") ?>', {comment: $('#comment').val()});
$.post('<?= esc("$controller_name/setComment") ?>', {comment: $('#comment').val()});
});

$('#recv_reference').keyup(function()
{
$.post('<?= esc("$controller_name/set_reference") ?>', {recv_reference: $('#recv_reference').val()});
$.post('<?= esc("$controller_name/setReference") ?>', {recv_reference: $('#recv_reference').val()});
});

$("#recv_print_after_sale").change(function()
{
$.post('<?= esc("$controller_name/set_print_after_sale") ?>', {recv_print_after_sale: $(this).is(":checked")});
$.post('<?= esc("$controller_name/setPrintAfterSale") ?>', {recv_print_after_sale: $(this).is(":checked")});
});

$('#item,#supplier').click(function()
Expand Down Expand Up @@ -569,7 +569,7 @@
{
if (confirm('<?= lang(ucfirst($controller_name) .'.confirm_cancel_receiving') ?>'))
{
$('#finish_receiving_form').attr('action', '<?= esc("$controller_name/cancel_receiving") ?>');
$('#finish_receiving_form').attr('action', '<?= esc("$controller_name/cancelReceiving") ?>');
$('#finish_receiving_form').submit();
}
});
Expand Down
4 changes: 2 additions & 2 deletions app/Views/sales/form.php
Expand Up @@ -166,7 +166,7 @@
<?php if(!empty($sale_info['email'])): ?>
$('#send_invoice').click(function(event) {
if (confirm("<?= lang('Sales.invoice_confirm') . ' ' . $sale_info['email'] ?>")) {
$.get("<?= esc("$controller_name/send_pdf/" . $sale_info['sale_id']) ?>",
$.get("<?= esc("$controller_name/sendPdf/" . $sale_info['sale_id']) ?>",
function(response) {
BootstrapDialog.closeAll();
$.notify( { message: response.message }, { type: response.success ? 'success' : 'danger'} )
Expand Down Expand Up @@ -245,7 +245,7 @@ function(response) {
{
remote:
{
url: "<?= esc("$controller_name/check_invoice_number") ?>",
url: "<?= esc("$controller_name/checkInvoiceNumber") ?>",
type: 'POST',
data: {
'sale_id': <?= $sale_info['sale_id'] ?>,
Expand Down
2 changes: 1 addition & 1 deletion app/Views/sales/invoice.php
Expand Up @@ -35,7 +35,7 @@
{
var send_email = function()
{
$.get('<?= site_url() . "sales/send_pdf/$sale_id_num" ?>',
$.get('<?= site_url() . "sales/sendPdf/$sale_id_num" ?>',
function(response)
{
$.notify({ message: response.message }, { type: response.success ? 'success' : 'danger'});
Expand Down
4 changes: 2 additions & 2 deletions app/Views/sales/quote.php
Expand Up @@ -31,7 +31,7 @@
{
var send_email = function()
{
$.get('<?= site_url() . esc("/sales/send_pdf/$sale_id_num/quote") ?>',
$.get('<?= site_url() . esc("/sales/sendPdf/$sale_id_num/quote") ?>',
function(response)
{
$.notify( { message: response.message }, { type: response.success ? 'success' : 'danger'} )
Expand All @@ -57,7 +57,7 @@ function(response)
<a href="javascript:void(0);"><div class="btn btn-info btn-sm" id="show_email_button"><?= '<span class="glyphicon glyphicon-envelope">&nbsp</span>' . lang('Sales.send_quote') ?></div></a>
<?php endif; ?>
<?= anchor('sales', '<span class=\'glyphicon glyphicon-shopping-cart\'>&nbsp</span>' . lang('Sales.register'), ['class' => 'btn btn-info btn-sm', 'id' => 'show_sales_button']) ?>
<?= anchor('sales/discard_suspended_sale', '<span class="glyphicon glyphicon-remove">&nbsp</span>' . lang('Sales.discard'), ['class' => 'btn btn-danger btn-sm', 'id' => 'discard_quote_button']) ?>
<?= anchor('sales/getDiscardSuspendedSale', '<span class="glyphicon glyphicon-remove">&nbsp</span>' . lang('Sales.discard'), ['class' => 'btn btn-danger btn-sm', 'id' => 'discard_quote_button']) ?>
</div>

<div id="page-wrap">
Expand Down

0 comments on commit 1296e28

Please sign in to comment.