A few tweaks for item maintenance

This commit is contained in:
Steve Ireland
2023-03-25 13:47:25 -04:00
parent 228801157c
commit 8cbc915741
4 changed files with 39 additions and 28 deletions

View File

@@ -211,9 +211,9 @@ class Items extends Secure_Controller
/**
* Gives search suggestions based on what is being searched for. Called from the view.
*/
public function suggest_category(): void
public function getSuggestCategory(): void
{
$suggestions = $this->item->get_category_suggestions($this->request->getVar('term', FILTER_SANITIZE_STRING));
$suggestions = $this->item->get_category_suggestions($this->request->getGet('term', FILTER_SANITIZE_STRING));
echo json_encode($suggestions);
}
@@ -221,14 +221,14 @@ class Items extends Secure_Controller
/**
* Gives search suggestions based on what is being searched for. Called from the view.
*/
public function suggest_location(): void
public function getSuggestLocation(): void
{
$suggestions = $this->item->get_location_suggestions($this->request->getVar('term', FILTER_SANITIZE_STRING));
$suggestions = $this->item->get_location_suggestions($this->request->getGet('term', FILTER_SANITIZE_STRING));
echo json_encode($suggestions);
}
public function getAjaxRow(string $item_ids): void //TODO: It's possible an array would be better.
public function getRow(string $item_ids): void //TODO: It's possible an array would be better.
{
$item_infos = $this->item->get_multiple_info(explode(':', $item_ids), $this->item_lib->get_item_location());
@@ -557,7 +557,11 @@ class Items extends Secure_Controller
public function postSave(int $item_id = NEW_ENTRY): void
{
$upload_success = $this->upload_image();
$upload_file = $this->request->hasFile('image') ? $this->request->getFile('image') : null; //TODO: https://codeigniter4.github.io/userguide/incoming/incomingrequest.html#uploaded-files
// TODO the hasFile is not defined, so commenting this out and saving it for last.
// $upload_file = $this->request->hasFile('image') ? $this->request->getFile('image') : null; //TODO: https://codeigniter4.github.io/userguide/incoming/incomingrequest.html#uploaded-files
$upload_file = null;
$receiving_quantity = parse_quantity($this->request->getPost('receiving_quantity', FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION));
$item_type = $this->request->getPost('item_type') === NULL ? ITEM : $this->request->getPost('item_type', FILTER_SANITIZE_NUMBER_INT);
@@ -608,10 +612,17 @@ class Items extends Secure_Controller
$item_data['tax_category_id'] = empty($this->request->getPost('tax_category_id')) ? NULL : $this->request->getPost('tax_category_id', FILTER_SANITIZE_NUMBER_INT);
}
$original_name = $upload_file->getFilename();
if(!empty($original_name))
if ($upload_file != NULL)
{
$item_data['pic_filename'] = $original_name;
$original_name = $upload_file->getFilename();
if(!empty($original_name))
{
$item_data['pic_filename'] = $original_name;
}
}
else
{
$item_data['pic_filename'] = NULL;
}
$employee_id = $this->employee->get_logged_in_employee_info()->person_id;
@@ -767,7 +778,7 @@ class Items extends Secure_Controller
}
public function check_item_number(): void
public function postCheckItemNumber(): void
{
$exists = $this->item->item_number_exists($this->request->getPost('item_number', FILTER_SANITIZE_STRING), $this->request->getPost('item_id', FILTER_SANITIZE_NUMBER_INT));
echo !$exists ? 'true' : 'false';
@@ -789,7 +800,7 @@ class Items extends Secure_Controller
echo !$exists ? 'true' : 'false';
}
public function remove_logo($item_id): void
public function getRemoveLogo($item_id): void
{
$item_data = ['pic_filename' => NULL];
$result = $this->item->save_value($item_data, $item_id);

View File

@@ -67,7 +67,7 @@ class Secure_Controller extends BaseController
view('viewData', $global_view_data);
}
public function check_numeric()
public function getCheckNumeric()
{
$result = TRUE;

View File

@@ -82,7 +82,7 @@
<div id="attributes">
<script type="text/javascript">
$('#attributes').load('<?php echo site_url("items/attributes/$item_info->item_id") ?>');
$('#attributes').load('<?php echo "items/attributes/$item_info->item_id" ?>');
</script>
</div>
@@ -501,7 +501,7 @@ $(document).ready(function()
};
$('#tax_category').autocomplete({
source: "<?php echo site_url('taxes/suggest_tax_categories') ?>",
source: "<?php echo 'taxes/suggestTaxCategories' ?>",
minChars: 0,
delay: 15,
cacheLength: 1,
@@ -517,7 +517,7 @@ $(document).ready(function()
};
$('#low_sell_item_name').autocomplete({
source: "<?php echo site_url('items/suggest_low_sell') ?>",
source: "<?php echo 'items/suggestLowSell' ?>",
minChars: 0,
delay: 15,
cacheLength: 1,
@@ -527,7 +527,7 @@ $(document).ready(function()
});
$('#category').autocomplete({
source: "<?php echo site_url('items/suggest_category') ?>",
source: "<?php echo 'items/suggestCategory' ?>",
delay: 10,
appendTo: '.modal-content'
});
@@ -535,7 +535,7 @@ $(document).ready(function()
$('a.fileinput-exists').click(function() {
$.ajax({
type: 'GET',
url: '<?php echo esc(site_url("$controller_name/remove_logo/$item_info->item_id"), 'url') ?>',
url: '<?php echo "$controller_name/removeLogo/$item_info->item_id" ?>',
dataType: 'json'
})
});
@@ -553,7 +553,7 @@ $(document).ready(function()
if(stay_open)
{
// set action of item_form to url without item id, so a new one can be created
$('#item_form').attr('action', "<?php echo site_url('items/save/') ?>");
$('#item_form').attr('action', "<?php echo 'items/save/' ?>");
// use a whitelist of fields to minimize unintended side effects
$(':text, :password, :file, #description, #item_form').not('.quantity, #reorder_level, #tax_name_1, #receiving_quantity, ' +
'#tax_percent_name_1, #category, #reference_number, #name, #cost_price, #unit_price, #taxed_cost_price, #taxed_unit_price, #definition_name, [name^="attribute_links"]').val('');
@@ -564,7 +564,7 @@ $(document).ready(function()
{
dialog_support.hide();
}
table_support.handle_submit('<?php echo site_url('items') ?>', response, stay_open);
table_support.handle_submit('<?php echo 'items' ?>', response, stay_open);
init_validation();
},
dataType: 'json'
@@ -582,7 +582,7 @@ $(document).ready(function()
required: false,
remote:
{
url: "<?php echo esc(site_url("$controller_name/check_item_number"), 'url') ?>",
url: "<?php echo esc("$controller_name/checkItemNumber") ?>",
type: 'POST',
data: {
'item_id' : "<?php echo $item_info->item_id ?>",
@@ -596,12 +596,12 @@ $(document).ready(function()
cost_price:
{
required: true,
remote: "<?php echo esc(site_url("$controller_name/check_numeric"), 'url') ?>"
remote: "<?php echo esc("$controller_name/checkNumeric") ?>"
},
unit_price:
{
required: true,
remote: "<?php echo esc(site_url("$controller_name/check_numeric"), 'url') ?>"
remote: "<?php echo esc("$controller_name/checkNumeric") ?>"
},
<?php
foreach($stock_locations as $key=>$location_detail)
@@ -610,7 +610,7 @@ $(document).ready(function()
<?php echo 'quantity_' . $key ?>:
{
required: true,
remote: "<?php echo esc(site_url("$controller_name/check_numeric"), 'url') ?>"
remote: "<?php echo esc("$controller_name/checkNumeric") ?>"
},
<?php
}
@@ -618,17 +618,17 @@ $(document).ready(function()
receiving_quantity:
{
required: true,
remote: "<?php echo esc(site_url("$controller_name/check_numeric"), 'url') ?>"
remote: "<?php echo esc("$controller_name/checkNumeric") ?>"
},
reorder_level:
{
required: true,
remote: "<?php echo esc(site_url("$controller_name/check_numeric"), 'url') ?>"
remote: "<?php echo esc("$controller_name/checkNumeric") ?>"
},
tax_percent:
{
required: true,
remote: "<?php echo esc(site_url("$controller_name/check_numeric"), 'url') ?>"
remote: "<?php echo esc("$controller_name/checkNumeric") ?>"
}
},

View File

@@ -1,4 +1,4 @@
<?php $this->lang->load('calendar'); $this->lang->load('date'); ?>
<?php $config = config('OSPOS')->settings; ?>
var pickerconfig = function(config) {
return $.extend({
@@ -25,7 +25,7 @@ var pickerconfig = function(config) {
todayHighlight: true,
bootcssVer: 3,
language: "<?php echo current_language_code() ?>"
}, <?php echo $config ?? '{}' ?>);
}, <?php '{}' ?>);
};
$.fn.datetimepicker.dates['<?php echo $config['language'] ?>'] = {