mirror of
https://github.com/opensourcepos/opensourcepos.git
synced 2026-01-02 06:27:50 -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.
53 lines
1.9 KiB
PHP
53 lines
1.9 KiB
PHP
<ul id="error_message_box" class="error_message_box"></ul>
|
|
|
|
<?php echo form_open_multipart('items/import_csv_file/', array('id'=>'csv_form', 'class'=>'form-horizontal')); ?>
|
|
<fieldset id="item_basic_info">
|
|
<div class="form-group form-group-sm">
|
|
<div class="col-xs-12">
|
|
<a href="<?php echo site_url('items/generate_csv_file'); ?>"><?php echo $this->lang->line('common_download_import_template'); ?></a>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="form-group form-group-sm">
|
|
<div class='col-xs-12'>
|
|
<div class="fileinput fileinput-new input-group" data-provides="fileinput">
|
|
<div class="form-control" data-trigger="fileinput"><i class="glyphicon glyphicon-file fileinput-exists"></i><span class="fileinput-filename"></span></div>
|
|
<span class="input-group-addon input-sm btn btn-default btn-file"><span class="fileinput-new"><?php echo $this->lang->line('common_import_select_file'); ?></span><span class="fileinput-exists"><?php echo $this->lang->line('common_import_change_file'); ?></span><input type="file" id="file_path" name="file_path" accept=".csv"></span>
|
|
<a href="#" class="input-group-addon input-sm btn btn-default fileinput-exists" data-dismiss="fileinput"><?php echo $this->lang->line('common_import_remove_file'); ?></a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</fieldset>
|
|
<?php echo form_close(); ?>
|
|
|
|
<script type="text/javascript">
|
|
//validation and submit handling
|
|
$(document).ready(function()
|
|
{
|
|
$('#csv_form').validate($.extend({
|
|
submitHandler: function(form) {
|
|
$(form).ajaxSubmit({
|
|
success:function(response)
|
|
{
|
|
dialog_support.hide();
|
|
table_support.handle_submit('<?php echo site_url('items'); ?>', response);
|
|
},
|
|
dataType: 'json'
|
|
});
|
|
},
|
|
|
|
errorLabelContainer: '#error_message_box',
|
|
|
|
rules:
|
|
{
|
|
file_path: 'required'
|
|
},
|
|
|
|
messages:
|
|
{
|
|
file_path: "<?php echo $this->lang->line('common_import_full_path'); ?>"
|
|
}
|
|
}, form_support.error));
|
|
});
|
|
</script>
|