mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-01-06 00:17:54 -05:00
Optimizations and CSV Import Rework - Replaced " with ' where possible to prevent the parser from being called when not needed. - Replaced == and != with === and !== where possible for bug prevention and speed. - Replaced -1 with NEW_ITEM global constant for code clarity. - Added NEW_ITEM global constant to constants.php. - Refactored CSV import function names for clarity. - Added capability to import a CSV file containing updates. - Replaced array() with [] for speed and consistency. - Removed hungarian notation from two private functions. - Refactored QueryBuilder functions to place table name in the get() function call. - Replaced (int) cast with call to intval() for speed. - Replaced == and != with === and !== where possible to prevent bugs and for speed. - Replaced array() with [] for speed and consistency. - Fixed search_custom call Optimizations and bugfixes for attributes used in csv_import - Reordered where statements in queries to match composite index on attribute_links table. - fixed value_exists() to account for different attribute types. - Removed hungarian notation on private function. - Replaced array() with [] for speed and consistency. - Replaced != with <> in SQL for consistency. - Removed from() calls in querybuilder where possible to reduce function calls. - Add get_items_by_value() - Reworked check_data_validity() - Remove unneeded comments - Refactor functions for code clarity. - Use $this->db->dbprefix() where possible instead of hand-writing ospos_... - Removed unneeded column from query. - Replaced (int) cast with intval() call for speed. - Added get_attribute_values() - Fixed issue with date format locale not being used - Refactored save_value to respect different attribute_types - Added delete_orphaned_links() to remove attribute_links that are no longer linked to any items - Added get_attributes_by_definition() - Added attribute_cleanup() Optimizations used in csv_import - replaced array() with [] for consistency and speed. - Removed hungarian notation in private functions. - Replaced " with ' where possible to prevent the parser from being called. - Minor formatting - Refactored if statement to tertiary notation for cleaner implementation. - Replaced " for ' where possible to prevent the parser from being called. - Added the Id column in the generate_import_items_csv() template so that users can submit an update to an existing item. - Removed unused key=>value pairs in foreach loops for speed. - Removed unneeded comments where the function name was self-explanatory. - Rework get_csv_file() for speed. - Rework bom_exists() for speed. - Replaced array() with [] for speed and consistency. - Replaced == with === where possible to prevent bugs and for speed. - Reworked valid_date() and valid_decimal helper functions for speed and accuracy according to the locale_format instead of a fixed format. - Minor Reformatting for clarity. - Replaced " for ' to prevent the parser from being called. - Refactored function call names to reflect new names. - Added missing ; in - Used String interpolation where useful. - Spelling fix in comment Requested Review Changes - Fixed indentation in Items.php - Fixed indentation in Attribute.php - Refactored variable out of long line of code to make it more readable.
100 lines
4.8 KiB
PHP
100 lines
4.8 KiB
PHP
<?php $this->load->view('partial/header'); ?>
|
|
|
|
<script type="text/javascript">
|
|
$(document).ready(function()
|
|
{
|
|
$('#generate_barcodes').click(function()
|
|
{
|
|
window.open(
|
|
'index.php/items/generate_barcodes/'+table_support.selected_ids().join(':'),
|
|
'_blank' // <- This is what makes it open in a new window.
|
|
);
|
|
});
|
|
|
|
// when any filter is clicked and the dropdown window is closed
|
|
$('#filters').on('hidden.bs.select', function(e)
|
|
{
|
|
table_support.refresh();
|
|
});
|
|
|
|
// load the preset daterange picker
|
|
<?php $this->load->view('partial/daterangepicker'); ?>
|
|
// set the beginning of time as starting date
|
|
$('#daterangepicker').data('daterangepicker').setStartDate("<?php echo date($this->config->item('dateformat'), mktime(0,0,0,01,01,2010));?>");
|
|
// update the hidden inputs with the selected dates before submitting the search data
|
|
var start_date = "<?php echo date('Y-m-d', mktime(0,0,0,01,01,2010));?>";
|
|
$("#daterangepicker").on('apply.daterangepicker', function(ev, picker) {
|
|
table_support.refresh();
|
|
});
|
|
|
|
$("#stock_location").change(function() {
|
|
table_support.refresh();
|
|
});
|
|
|
|
<?php $this->load->view('partial/bootstrap_tables_locale'); ?>
|
|
|
|
table_support.init({
|
|
employee_id: <?php echo $this->Employee->get_logged_in_employee_info()->person_id; ?>,
|
|
resource: '<?php echo site_url($controller_name);?>',
|
|
headers: <?php echo $table_headers; ?>,
|
|
pageSize: <?php echo $this->config->item('lines_per_page'); ?>,
|
|
uniqueId: 'items.item_id',
|
|
queryParams: function() {
|
|
return $.extend(arguments[0], {
|
|
start_date: start_date,
|
|
end_date: end_date,
|
|
stock_location: $("#stock_location").val(),
|
|
filters: $("#filters").val() || [""]
|
|
});
|
|
},
|
|
onLoadSuccess: function(response) {
|
|
$('a.rollover').imgPreview({
|
|
imgCSS: { width: 200 },
|
|
distanceFromCursor: { top:10, left:-210 }
|
|
})
|
|
}
|
|
});
|
|
});
|
|
</script>
|
|
|
|
<div id="title_bar" class="btn-toolbar print_hide">
|
|
<button class='btn btn-info btn-sm pull-right modal-dlg' data-btn-submit='<?php echo $this->lang->line('common_submit') ?>' data-href='<?php echo site_url("$controller_name/csv_import"); ?>'
|
|
title='<?php echo $this->lang->line('items_import_items_csv'); ?>'>
|
|
<span class="glyphicon glyphicon-import"> </span><?php echo $this->lang->line('common_import_csv'); ?>
|
|
</button>
|
|
|
|
<button class='btn btn-info btn-sm pull-right modal-dlg' data-btn-new='<?php echo $this->lang->line('common_new') ?>' data-btn-submit='<?php echo $this->lang->line('common_submit') ?>' data-href='<?php echo site_url("$controller_name/view"); ?>'
|
|
title='<?php echo $this->lang->line($controller_name . '_new'); ?>'>
|
|
<span class="glyphicon glyphicon-tag"> </span><?php echo $this->lang->line($controller_name. '_new'); ?>
|
|
</button>
|
|
</div>
|
|
|
|
<div id="toolbar">
|
|
<div class="pull-left form-inline" role="toolbar">
|
|
<button id="delete" class="btn btn-default btn-sm print_hide">
|
|
<span class="glyphicon glyphicon-trash"> </span><?php echo $this->lang->line('common_delete'); ?>
|
|
</button>
|
|
<button id="bulk_edit" class="btn btn-default btn-sm modal-dlg print_hide", data-btn-submit='<?php echo $this->lang->line('common_submit') ?>', data-href='<?php echo site_url("$controller_name/bulk_edit"); ?>'
|
|
title='<?php echo $this->lang->line('items_edit_multiple_items'); ?>'>
|
|
<span class="glyphicon glyphicon-edit"> </span><?php echo $this->lang->line("items_bulk_edit"); ?>
|
|
</button>
|
|
<button id="generate_barcodes" class="btn btn-default btn-sm print_hide" data-href='<?php echo site_url("$controller_name/generate_barcodes"); ?>' title='<?php echo $this->lang->line('items_generate_barcodes');?>'>
|
|
<span class="glyphicon glyphicon-barcode"> </span><?php echo $this->lang->line('items_generate_barcodes'); ?>
|
|
</button>
|
|
<?php echo form_input(array('name'=>'daterangepicker', 'class'=>'form-control input-sm', 'id'=>'daterangepicker')); ?>
|
|
<?php echo form_multiselect('filters[]', $filters, '', array('id'=>'filters', 'class'=>'selectpicker show-menu-arrow', 'data-none-selected-text'=>$this->lang->line('common_none_selected_text'), 'data-selected-text-format'=>'count > 1', 'data-style'=>'btn-default btn-sm', 'data-width'=>'fit')); ?>
|
|
<?php
|
|
if (count($stock_locations) > 1)
|
|
{
|
|
echo form_dropdown('stock_location', $stock_locations, $stock_location, array('id'=>'stock_location', 'class'=>'selectpicker show-menu-arrow', 'data-style'=>'btn-default btn-sm', 'data-width'=>'fit'));
|
|
}
|
|
?>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="table_holder">
|
|
<table id="table"></table>
|
|
</div>
|
|
|
|
<?php $this->load->view('partial/footer'); ?>
|