Commit Graph

53 Commits

Author SHA1 Message Date
objecttothis
3d65c3fffa CSV import optimizations and code cleanup (#3150)
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 &nbsp;
- 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.
2021-07-29 22:22:59 +02:00
objecttothis
97159d42c7 Database Optimizations
- Add indexes to tables to improve query times.
- Delete orphaned attribute values.
- Resolve duplicate attribute values.
- Deleted whitespace after migration which was causing Severity: Warning --> Cannot modify header information - headers already sent by
2021-05-25 14:04:01 +02:00
objecttothis
a3fb05b566 Change the locations of global constants to make them global across
files

- Items Constants
- Attributes Constants
- Sale Constants
2020-06-03 14:15:05 +04:00
objecttothis
89a56820d2 Formatting Corrections 2020-05-20 13:52:54 +04:00
objecttothis
145f49d247 Code Review Changes
- Refactored code to include constants
- Fixed comment formatting issues
2020-05-20 13:48:24 +04:00
objecttothis
f5424a3ed2 Create Global Constants to clarify code 2020-05-19 18:06:20 +04:00
objecttothis
1dc3e15a55 Implement dropdown into item form view
- Created business logic in view to show dropdown if enabled
- Created business logic in controller to calculate key/value pairs of
dropdown
- Adjusted attribute model get_definition values to send values also if
definition_id is -1 or > 0 but not 0 which is what we are now using as
no definition instead of -1
2020-05-05 11:59:03 +04:00
objecttothis
0051fa87ec Corrected errors 2020-05-04 17:18:48 +04:00
objecttothis
15a987cfd9 Adjust functions related to attributes 2020-05-04 17:00:02 +04:00
objecttothis
96bfa330ba Added the creation and removal of ospos_category attribute
- Added undelete function in Attribute model which could be useful for
adding the ability to restore attributes once deleted.
- Added business logic to Config controller save_general to
create/remove the attribute when the box is checked or unchecked.
2020-05-04 16:45:58 +04:00
objecttothis
42f8d71404 Added ORDER BY to sort various dropdowns
This sorts alphabetically:
- Attributes on the Attribute->Item view
- Dropdowns for adding attributes in the Attribute->Item view
- Dropdowns for the attribute values themselves.
2020-04-30 17:12:59 +04:00
objecttothis
b0ba354b31 Values is a mysql keyword
Corrected the name of the alias from values to vals to prevent DB errors on conversion from DROPDOWN to CHECKBOX.
2020-04-22 13:37:31 +04:00
objecttothis
b5265870be More descriptive alias 2020-03-24 14:21:57 +04:00
objecttothis
8a0c88b11c More indentation corrections 2020-03-24 14:13:08 +04:00
objecttothis
3281fc9bb0 Correct indentation problems 2020-03-24 14:04:04 +04:00
objecttothis
fb9fec1a10 Merge branch 'master' into pos_bool 2020-03-18 16:19:45 +04:00
objecttothis
cefd287668 Resolve bug not updating attributes correctly
Prior to this fix, if the attribute was of DECIMAL or DATE type and the action was an UPDATE, then it would try to update the attribute_value, not the corresponding attribute_decimal or attribute_date.
2020-03-10 09:21:09 +01:00
objecttothis
ea7cb48f1c CHECKBOX Attribute type
Conversion from DROPDOWN or TEXT logic
2020-03-02 14:17:48 +04:00
objecttothis
ff79b73e34 Implement CHECKBOX attribute type
Attribute Configuration view
Attributes section of item management view
Attributes section of CSV item import
2020-02-25 15:44:49 +04:00
jekkos
55c86afcde Fix warning in development mode (#2476) 2019-09-23 07:55:44 +02:00
objecttothis
8c173540e6 Update Attribute.php
changed DATETIME to DATE since constant name was changed but it wasn't changed here.
2019-07-09 18:05:23 +04:00
jekkos
8ca5449b79 Add decimals to items search result + fix reports 2019-06-20 18:39:17 +02:00
FrancescoUK
01dfd023eb Merge pull request #2319 from opensourcepos/fix-attribute-datetime
Fix attribute datetime formatting
2019-06-15 10:32:22 +01:00
FrancescoUK
4644dd2e46 MySQL queries consistency check 2019-06-15 09:39:08 +01:00
jekkos
0ae6470b35 Migrate attribute datetime to date (#2441) 2019-06-05 00:47:17 +02:00
jekkos
d3d051ee72 Fix loading attribute values in item search (#2232) 2019-06-05 00:31:45 +02:00
jekkos
f2d2b1d3e2 Fix datetime attribute formatting (#2232) 2019-06-05 00:29:48 +02:00
FrancescoUK
dbf3114267 Attributes csv import integration 2019-06-03 21:13:21 +01:00
objecttothis
185cf88534 Update Attribute.php
Remove blank line
2019-03-14 10:05:39 +04:00
objecttothis
2dca4785e1 Update Attribute.php
Without this else if the change from text to dropdown fails but no actual query is made since the query to update the attribute type gets made by the save_definition function.
2019-03-14 10:04:46 +04:00
objecttothis
f875c8e518 Changes to allow attribute type of DECIMAL 2019-03-01 17:48:20 +04:00
objecttothis
aea080d6bd Update Attribute.php
Without this else, TEXT->DROPDOWN fails.  It just returns a simple success because no database changes are needed other than changing the definition_type which is not done here.  This would also cause all other conversions not listed to automatically succeed, but we don't need to worry because those are restricted in the view to only ones that are actually supported.
2019-02-26 14:08:33 +04:00
objecttothis
3b3b58bda4 Refactor regex to locale_helper to be used in other parts of the code. 2019-02-21 15:04:48 +04:00
objecttothis
fd99df8c2e combined nested if statement into single if 2019-02-21 12:23:44 +04:00
objecttothis
20af6120b1 Corrections to $success 2019-02-20 10:32:40 +04:00
objecttothis
7875ecaa5b Corrected $success references 2019-02-19 10:46:27 +04:00
objecttothis
c631cdbaf4 Added code to error out on incorrectly formatted data. 2019-02-18 17:02:12 +04:00
objecttothis
81033f55e5 Corrected code 2019-02-18 12:37:11 +04:00
objecttothis
e66c7bad24 Add attribute type conversion, error checking. 2019-02-15 17:03:31 +04:00
objecttothis
2c06edba02 Remove function and combine call to reduce redundant code. 2019-01-30 11:30:28 +04:00
objecttothis
e080873ec3 Check to see if attribute_value already exists 2019-01-28 18:16:17 +04:00
jekkos
afbb06eaad Fix issue with PHP7.2 (#2190) 2018-11-03 20:19:19 +01:00
jekkos
2fc353cd14 Don't show GROUP attribute as column (#68) 2018-10-15 19:32:29 +02:00
jekkos
77682973a0 Enable attributes in items table (#68) 2018-10-15 19:32:29 +02:00
jekkos
288b4029d7 Add attributes to detailed sales/receiving reports (#68) 2018-10-15 19:32:29 +02:00
FrancescoUK
6bbf927d81 Update Attribute.php 2018-10-15 19:32:29 +02:00
jekkos
085d24447c Disablel SHOW_IN_ITEMS (#68) 2018-10-15 19:32:29 +02:00
jekkos
8b212a8dd0 Fix some final bugs (#68) 2018-10-15 19:32:29 +02:00
jekkos
1a490cedf5 Add support for DATETIME in attributes (#68) 2018-10-15 19:32:29 +02:00
jekkos
1e0063e574 Fix attribute table refresh (#68) 2018-10-15 19:32:29 +02:00