#===============================================================================
#
# Eng-DB-2 - a light-weight engineering database
# Copyright (c) 2010, Felix Bertram
#
# Eng-DB-2 is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Eng-DB-2 is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Eng-DB-2. If not, see <http://www.gnu.org/licenses/>.
#
#-------------------------------------------------------------------------------
# File: eng_db.pl
# History: FB, 2010sep17 - created.
# FB, 2010oct21 - now running on Windows
# FB, 2010dec13 - added format for quote.txt w/o currency spec
# FB, 2010dec16 - xref.txt can now contain comment lines
# FB, 2010dec20 - fixed issues with parsing quote.txt
# FB, 2011jan04 - added price.txt
# FB, 2011jan10 - v1.4: price.txt now accepts currency
# FB, 2011jan12 - v1.5: improved Excel colors for assemblies
# FB, 2011jan12 - v1.6: improved Excel: added autofilter to part master
# FB, 2011jan12 - v1.7: improved Excel: divided module's summed u/p by e/qty
# FB, 2011jan13 - improved Excel: provide sanitized BOM as well
# FB, 2011jan17 - v1.8: improved Excel: build PARTS file as well
# FB, 2011jan18 - v1.9: added where-used search
# FB, 2011jan18 - v1.10: fixed handling of SVN folders
# FB, 2011jan25 - v1.11: prod prints list when unknown product is specified
# FB, 2011jan25 - v1.12: open product folder after bldbom
# - hide quote columns when %quote is empty
# - fix position of split on parts list
# FB, 2011jan26 - Excel BOM: show part rev (as part of description)
# - Excel BOM: show outline symbols ABOVE folded lines
# - Excel outputs: setting tab color
# FB, 2011mar07 - Excel BOM: preceed level with asterisks
# FB, 2011apr14 - v1.13: Excel BOM: fix formatting or rev on parts master
# FB, 2011apr18 - v1.14b: added updprice command
# FB, 2011may11 - v1.15b: fixed a warning for hidden variable
# FB, 2011jul12 - v1.16b: do not export folders starting with _
# FB, 2011jul28 - v1.17b: bldbom: fix path separator for Windows
# FB, 2011aug25 - v1.18b: fix readLibraryDir to read files in
# specific order; this fixes issues with currencies
# unknown at the time of loading a part
# FB, 2011sep06 - v1.19b: print descr field from quote.txt on Excel
# FB, 2011sep08 - v1.20b: add part substitution feature
# FB, 2011sep28 - v1.21b: fix currency issues with duplicate quotes
# FB, 2011sep29 - v1.22b: fix handling of info.txt.txt (died during export)
# FB, 2012feb22 - v1.23b: added pi_eco field
# FB, 2012apr18 - v1.24b: read local lib first, this is
# to fix issue with subst in global lib
# CHANGE undone - doesn't work with foreign-currency quotes
# FB, 2012jun15 - v1.25b: allow negative quotes
# FB, 2012aug20 - v1.26b: remove whitespace when parsing SKU= lines
# FB, 2012sep19 - v1.27b: added hyperlink from BOM to part master
# added hyperlink from part master to server
# FB, 2012oct23 - v1.28b: added support for hyperlinks to local files
# FB, 2012oct23 - v1.29b: changed pi_info to relative path
# JH, 2013????? - added import tool
# added 'alias' token to info.txt
# JH, 2013sep17 - v1.30b: added 'pricesrc' token to info.txt to indicate where a price came from
# FB, 2013nov22 - v1.31b: added custom cells to title page (token cell_c, cell_s)
# FB, 2013dec04 - v1.32b: calculate quoted price for use as KPI
# JH, 2014jan23 - v1.33b: fixed comparing import header names using upper case
# JH, 2014apr01 - v1.34b: added importing of price source column
# FB, 2014apr01 - v1.35b: added $db_path to _updatePriceInfo
# FB, 2014apr08 - v1.36b: updprice now pushes quote name back into pricesrc
# FB, 2014apr17 - v1.37b: updprice: skip if update==0, refreshLibrary
# FB, 2014apr22 - v1.38b: added supplier token to info.txt
# FB, 2014sep09 - v1.39b: added flag token for info.txt
# JH, 2014sep09 - v1.40b: added printing of flag token to 'find'
# FB, 2014nov13 - v1.41b: added path-based subst
# 2014nov13 - v1.42b: fixed path-based subst
# JH, 2014nov18 - v1.43b: added 'check' functionality, checking price, pricesrc and avl
# JH, 2015jan05 - v1.44b: added checking price == pricesrc to 'check' functionality
# JH, 2015jun22 - v1.45b: fixed 'explodeProduct' to use upper-case product name to search for
# in library. Was affecting 'where' command for lower-case product names, since
# part lib only contains upper-case names, so product would not be found.
# JH, 2015jul29 - v1.46b: added support for comma ',' in price tags for supporting european price format
# added rudimentory unit testing for this issue. Commented out in release.
# Nothing to be proud of.
# JH, 2015dec23 - v1.47b: commented-out support for comma ',' in price tags for supporting european price
# format as it would likely confuse and complicate things down the road.
#
#
#===============================================================================