<MvCOMMENT>
|
| Miva Merchant v4.x
|
| This file and the source codes contained herein are the property 
| of Miva Corporation.  Use of this file is restricted to the specific 
| terms and conditions in the License Agreement associated with this 
| file.  Distribution of this file or portions of this file for uses
| not covered by the License Agreement is not allowed without a written 
| agreement signed by an officer of Miva Corporation.
| 
| Copyright 1998-2001 Miva Corporation.  All rights reserved.
| http://www.miva.com/
|
| dBase III Database Layer
| $Source: /home/cvs/merchant/Merchant/features/att/att_db.mv,v $
|
| Prefix         : MER-ATT-DTB-
| Next Error Code: 32   
| Next Text ID   : 16   
|
</MvCOMMENT>

<MvCOMMENT>
|
| Attribute Templates
|
</MvCOMMENT>

<MvFUNCTION NAME = "ATT_Create_Data_Files" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = "1">

	<MvLOCALIZED NAME = "l.privilege" ID = "MER-ATT-DTB-00012">
		<MvLOCALIZED-TEXT LANGUAGE = "en-US">Attribute Templates</MvLOCALIZED-TEXT>
	</MvLOCALIZED>
	<MvDO FILE = "{ g.Module_Library_DB }" NAME = "l.ok" VALUE = "{ Privilege_Insert( 'ATMP', l.privilege ) }">

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "_AttributeTemplates_Filter" PARAMETERS = "search" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.word" VALUE = "1">
	<MvASSIGN NAME = "g._state_word" INDEX = "{ l.word }" VALUE = "{ gettoken( l.search, ' ', l.word ) }">
	<MvWHILE EXPR = "{ g._state_word[ l.word ] }">
		<MvASSIGN NAME = "l.word" VALUE = "{ l.word + 1 }">
		<MvASSIGN NAME = "g._state_word" INDEX = "{ l.word }" VALUE = "{ gettoken( l.search, ' ', l.word ) }">
	</MvWHILE>																		   

	<MvASSIGN NAME = "l.filter" VALUE = "( NOT AttributeTemplates.d.deleted )">
	<MvASSIGN NAME = "l.pos" VALUE = "1">
	<MvWHILE EXPR = "{ l.pos LE ( l.word - 1 ) }">
		<MvASSIGN NAME = "l.filter" VALUE = "{ l.filter $ ' AND (
			( g._state_word[' $ l.pos $ '] CIN AttributeTemplates.d.code ) OR
			( g._state_word[' $ l.pos $ '] CIN AttributeTemplates.d.name ) OR 						
			( g._state_word[' $ l.pos $ '] CIN AttributeTemplates.d.prompt ) )' }">
		<MvASSIGN NAME = "l.pos" VALUE = "{ l.pos + 1 }">
	</MvWHILE>

	<MvFUNCTIONRETURN VALUE = "{ l.filter }">
</MvFUNCTION>

<MvFUNCTION NAME = "_DB_Store_Open_AttributeTemplates" STANDARDOUTPUTLEVEL = "" ERROROUTPUTLEVEL = "syntax, expression">
	<MvASSIGN NAME = "l.ok" VALUE = "1">

	<MvIF EXPR = "{ NOT g._DB_Store_AttributeTemplates_Open }">
		<MvOPEN NAME = "AttributeTemplates" 
				DATABASE = "{ g._DB_Store_Directory $ 'attempl.dbf' }" 
				INDEXES = "{ g._DB_Store_Directory $ 'attemplc.mvx' $ ',' $ g._DB_Store_Directory $ 'attempli.mvx' }">
		<MvIF EXPR = "{ MvOPEN_Error }">
			<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-ATT-DTB-00001', MvOPEN_Error ) }">
		<MvELSE>
			<MvASSIGN NAME = "g._DB_Store_AttributeTemplates_Open" VALUE = "1">
			<MvFILTER NAME = "AttributeTemplates" FILTER = "{ NOT AttributeTemplates.d.deleted }">
		</MvIF>
	</MvIF>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "ATT_Store_Pack" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = "{ _DB_Store_Open_AttributeTemplates() }">
	<MvIF EXPR = "{ l.ok }">
		<MvPACK NAME = "AttributeTemplates">
		<MvIF EXPR = "{ MvPACK_Error }">
			<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-ATT-DTB-00025', MvPACK_Error ) }">
		<MvELSE>
			<MvCLOSE NAME = "AttributeTemplates">
			<MvASSIGN NAME = "g._DB_Store_AttributeTemplates_Open" VALUE = "0">
		</MvIF>
	</MvIF>

	<MvASSIGN NAME = "l.ok" VALUE = "{ _DB_Store_Open_AttributeTemplateOptions() }">
	<MvIF EXPR = "{ l.ok }">
		<MvPACK NAME = "AttributeTemplateOptions">
		<MvIF EXPR = "{ MvPACK_Error }">
			<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-ATT-DTB-00026', MvPACK_Error ) }">
		<MvELSE>
			<MvCLOSE NAME = "AttributeTemplateOptions">
			<MvASSIGN NAME = "g._DB_Store_AttributeTemplateOptions_Open" VALUE = "0">
		</MvIF>
	</MvIF>

	<MvASSIGN NAME = "l.ok" VALUE = "{ _DB_Store_Open_AttributeTemplateAttributes() }">
	<MvIF EXPR = "{ l.ok }">
		<MvPACK NAME = "AttributeTemplateAttributes">
		<MvIF EXPR = "{ MvPACK_Error }">
			<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-ATT-DTB-00027', MvPACK_Error ) }">
		<MvELSE>
			<MvCLOSE NAME = "AttributeTemplateAttributes">
			<MvASSIGN NAME = "g._DB_Store_AttributeTemplateAttributes_Open" VALUE = "0">
		</MvIF>
	</MvIF>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "ATT_Store_Delete" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = 1>
	<MvASSIGN NAME = "l.directory" VALUE = "{ g.MerchantPath $ padl( Stores.d.id, 8, '0' ) $ '/' }">

	<MvASSIGN NAME = "l.deleted" VALUE = "{ fdelete( l.directory $ 'attmpop.dbf' ) }">
	<MvASSIGN NAME = "l.deleted" VALUE = "{ fdelete( l.directory $ 'attmpop.dbt' ) }">
	<MvASSIGN NAME = "l.deleted" VALUE = "{ fdelete( l.directory $ 'attmpopa.mvx' ) }">
	<MvASSIGN NAME = "l.deleted" VALUE = "{ fdelete( l.directory $ 'attmpopc.mvx' ) }">
	<MvASSIGN NAME = "l.deleted" VALUE = "{ fdelete( l.directory $ 'attmpopi.mvx' ) }">
	<MvASSIGN NAME = "l.deleted" VALUE = "{ fdelete( l.directory $ 'attempl.dbf' ) }">
	<MvASSIGN NAME = "l.deleted" VALUE = "{ fdelete( l.directory $ 'attemplc.mvx' ) }">
	<MvASSIGN NAME = "l.deleted" VALUE = "{ fdelete( l.directory $ 'attempli.mvx' ) }">
	<MvASSIGN NAME = "l.deleted" VALUE = "{ fdelete( l.directory $ 'atmpatt.dbf' ) }">
	<MvASSIGN NAME = "l.deleted" VALUE = "{ fdelete( l.directory $ 'atmpatt.dbt' ) }">
	<MvASSIGN NAME = "l.deleted" VALUE = "{ fdelete( l.directory $ 'atmpatta.mvx' ) }">
	<MvASSIGN NAME = "l.deleted" VALUE = "{ fdelete( l.directory $ 'atmpattc.mvx' ) }">
	<MvASSIGN NAME = "l.deleted" VALUE = "{ fdelete( l.directory $ 'atmpatti.mvx' ) }">
	<MvASSIGN NAME = "l.deleted" VALUE = "{ fdelete( l.directory $ 'atmpattp.mvx' ) }">

	<MvFUNCTIONRETURN VALUE = 1>
</MvFUNCTION>

<MvFUNCTION NAME = "ATT_Store_Close" STANDARDOUTPUTLEVEL = "">
	<MvIF EXPR = "{ g._DB_Store_AttributeTemplateOptions_Open }">
		<MvCLOSE NAME = "AttributeTemplateOptions">
		<MvASSIGN NAME = "g._DB_Store_AttributeTemplateOptions_Open" VALUE = "0">
	</MvIF>

	<MvIF EXPR = "{ g._DB_Store_AttributeTemplates_Open }">
		<MvCLOSE NAME = "AttributeTemplates">
		<MvASSIGN NAME = "g._DB_Store_AttributeTemplates_Open" VALUE = "0">
	</MvIF>

	<MvIF EXPR = "{ g._DB_Store_AttributeTemplateAttributes_Open }">
		<MvCLOSE NAME = "AttributeTemplateAttributes">
		<MvASSIGN NAME = "g._DB_Store_AttributeTemplateAttributes_Open" VALUE = "0">
	</MvIF>

	<MvFUNCTIONRETURN VALUE = 1>
</MvFUNCTION>

<MvFUNCTION NAME = "AttributeTemplate_Increment_ReferenceCount" PARAMETERS = "id" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = "{ _DB_Store_Open_AttributeTemplates() }">
	<MvIF EXPR = "{ l.ok }">
		<MvPRIMARY NAME = "AttributeTemplates" INDEX = "{ g._DB_Store_Directory $ 'attempli.mvx' }">
		<MvFIND NAME = "AttributeTemplates" VALUE = "{ l.id }" EXACT>
		<MvIF EXPR = "{ AttributeTemplates.d.EOF }">
			<MvLOCALIZED NAME = "l.error" ID = "MER-ATT-DTB-00013">
				<MvLOCALIZED-TEXT LANGUAGE = "en-US">Attribute Template not found</MvLOCALIZED-TEXT>
			</MvLOCALIZED>

			<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-ATT-DTB-00029', l.error ) }">
		<MvELSE>
			<MvLOCKFILE FILE = "{ g._DB_Store_Directory $ 'attempl.dbf' }">
				<MvASSIGN NAME = "AttributeTemplates.d.refcount" VALUE = "{ AttributeTemplates.d.refcount + 1 }">
				<MvUPDATE NAME = "AttributeTemplates">
			</MvLOCKFILE>
		</MvIF>
	</MvIF>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "AttributeTemplate_Decrement_ReferenceCount" PARAMETERS = "id" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = "{ _DB_Store_Open_AttributeTemplates() }">
	<MvIF EXPR = "{ l.ok }">
		<MvPRIMARY NAME = "AttributeTemplates" INDEX = "{ g._DB_Store_Directory $ 'attempli.mvx' }">
		<MvFIND NAME = "AttributeTemplates" VALUE = "{ l.id }" EXACT>
		<MvIF EXPR = "{ AttributeTemplates.d.EOF }">
			<MvLOCALIZED NAME = "l.error" ID = "MER-ATT-DTB-00014">
				<MvLOCALIZED-TEXT LANGUAGE = "en-US">Attribute Template not found</MvLOCALIZED-TEXT>
			</MvLOCALIZED>

			<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-ATT-DTB-00030', l.error ) }">
		<MvELSE>
			<MvLOCKFILE FILE = "{ g._DB_Store_Directory $ 'attempl.dbf' }">
				<MvIF EXPR = "{ AttributeTemplates.d.refcount GT 0 }">
					<MvASSIGN NAME = "AttributeTemplates.d.refcount" VALUE = "{ AttributeTemplates.d.refcount - 1 }">
					<MvUPDATE NAME = "AttributeTemplates">
				</MvIF>
			</MvLOCKFILE>
		</MvIF>
	</MvIF>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "AttributeTemplates_Insert" PARAMETERS = "code, prompt" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = "{ _DB_Store_Open_AttributeTemplates() }">

	<MvDO FILE = "{ g.Module_Library_DB }" NAME = "l.key" VALUE = "{ StoreKey_Generate( 'AttributeTemplates' ) }">

	<MvIF EXPR = "{ l.ok }">
		<MvASSIGN NAME = "AttributeTemplates.d.id" VALUE = "{ l.key }">
		<MvASSIGN NAME = "AttributeTemplates.d.code" VALUE = "{ ltrim( rtrim( l.code ) ) }">
		<MvASSIGN NAME = "AttributeTemplates.d.prompt" VALUE = "{ l.prompt }">
		<MvASSIGN NAME = "AttributeTemplates.d.refcount" VALUE = 0>

		<MvADD NAME = "AttributeTemplates">
	</MvIF>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "AttributeTemplate_Update" PARAMETERS = "old_code, code, prompt" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = "{ _DB_Store_Open_AttributeTemplates() }">
	<MvIF EXPR = "{ l.ok }">
		<MvPRIMARY NAME = "AttributeTemplates" INDEX = "{ g._DB_Store_Directory $ 'attemplc.mvx' }">
		<MvFIND NAME = "AttributeTemplates" VALUE = "{ toupper( l.old_code ) }" EXACT>
		<MvIF EXPR = "{ AttributeTemplates.d.EOF }">
			<MvLOCALIZED NAME = "l.error" ID = "MER-ATT-DTB-00001">
				<MvLOCALIZED-TOKEN NAME = "code" VALUE = "{ encodeentities( l.old_code ) }">
				<MvLOCALIZED-TEXT LANGUAGE = "en-US">Attribute Template '%code%' not found</MvLOCALIZED-TEXT>
			</MvLOCALIZED>

			<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-ATT-DTB-00002', l.error ) }">
		<MvELSE>
			<MvASSIGN NAME = "AttributeTemplates.d.code" VALUE = "{ l.code }">
			<MvASSIGN NAME = "AttributeTemplates.d.prompt" VALUE = "{ l.prompt }">
			<MvUPDATE NAME = "AttributeTemplates">
		</MvIF>
	</MvIF>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "AttributeTemplate_Delete" PARAMETERS = "code" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = "{ _DB_Store_Open_AttributeTemplates() }">
	<MvPRIMARY NAME = "AttributeTemplates" INDEX = "{ g._DB_Store_Directory $ 'attemplc.mvx' }">
	<MvIF EXPR = "{ l.ok }">
		<MvFIND NAME = "AttributeTemplates" VALUE = "{ toupper( l.code ) }" EXACT>
		<MvIF EXPR = "{ AttributeTemplates.d.EOF }">
			<MvLOCALIZED NAME = "l.error" ID = "MER-ATT-DTB-00002">
				<MvLOCALIZED-TOKEN NAME = "code" VALUE = "{ encodeentities( l.code ) }">
				<MvLOCALIZED-TEXT LANGUAGE = "en-US">Attribute Template '%code%' not found</MvLOCALIZED-TEXT>
			</MvLOCALIZED>

			<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-ATT-DTB-00003', l.error ) }">
		<MvELSE>
			<MvASSIGN NAME = "l.found" VALUE = "{ AttributeTemplateAttribute_FindFirst_AttributeTemplate( AttributeTemplates.d.id ) }">
			<MvWHILE EXPR = "{ l.found }">
				<MvASSIGN NAME = "l.found_option" VALUE = "{ AttributeTemplateOption_FindFirst_Attribute( AttributeTemplateAttributes.d.id ) }">
				<MvWHILE EXPR = "{ l.found_option }">
					<MvASSIGN NAME = "l.ok" VALUE = "{ AttributeTemplateOption_Delete( AttributeTemplateOptions.d.id ) }">

					<MvASSIGN NAME = "l.found_option" VALUE = "{ AttributeTemplateOption_FindNext_Attribute( AttributeTemplateAttributes.d.id ) }">
				</MvWHILE>

				<MvASSIGN NAME = "l.ok" VALUE = "{ AttributeTemplateAttribute_Delete( AttributeTemplateAttributes.d.id ) }">

				<MvASSIGN NAME = "l.found" VALUE = "{ AttributeTemplateAttribute_FindNext_AttributeTemplate( AttributeTemplates.d.id ) }">
			</MvWHILE>

			<MvIF EXPR = "{ l.ok }">
				<MvIF EXPR = "{ AttributeTemplates.d.refcount GT 0 }">
					<MvLOCALIZED NAME = "l.error" ID = "MER-ATT-DTB-00015">
						<MvLOCALIZED-TOKEN NAME = "code" VALUE = "{ encodeentities( l.code ) }">
						<MvLOCALIZED-TEXT LANGUAGE = "en-US">Attribute Template '%code%' is in use by one or more products</MvLOCALIZED-TEXT>
					</MvLOCALIZED>

					<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-ATT-DTB-00031', l.error ) }">
				<MvELSE>
					<MvDELETE NAME = "AttributeTemplates">
				</MvIF>
			</MvIF>
		</MvIF>
	</MvIF>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "AttributeTemplate_Find_ID" PARAMETERS = "id" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.found" VALUE = "0">
	<MvIF EXPR = "{ _DB_Store_Open_AttributeTemplates() }">
		<MvPRIMARY NAME = "AttributeTemplates" INDEX = "{ g._DB_Store_Directory $ 'attempli.mvx' }">
		<MvFIND NAME = "AttributeTemplates" VALUE = "{ l.id }" EXACT>
		<MvIF EXPR = "{ NOT AttributeTemplates.d.EOF }">
			<MvASSIGN NAME = "l.found" VALUE = "1">
		</MvIF>
	</MvIF>

	<MvFUNCTIONRETURN VALUE = "{ l.found }">
</MvFUNCTION>

<MvFUNCTION NAME = "AttributeTemplate_Find_Code" PARAMETERS = "code" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.found" VALUE = "0">
	<MvIF EXPR = "{ _DB_Store_Open_AttributeTemplates() }">
		<MvPRIMARY NAME = "AttributeTemplates" INDEX = "{ g._DB_Store_Directory $ 'attemplc.mvx' }">
		<MvFIND NAME = "AttributeTemplates" VALUE = "{ toupper( l.code ) }" EXACT>
		<MvIF EXPR = "{ NOT AttributeTemplates.d.EOF }">
			<MvASSIGN NAME = "l.found" VALUE = "1">
		</MvIF>
	</MvIF>

	<MvFUNCTIONRETURN VALUE = "{ l.found }">
</MvFUNCTION>

<MvFUNCTION NAME = "Attribute_Find_TemplateID" PARAMETERS = "attemp_id" STANDARDOUTPUTLEVEL = "">
	<MvDO FILE = "{ g.Module_Library_DB }" NAME = "l.ok" VALUE = "{ _DB_Store_Open_Attributes() }">
	
	<MvIF EXPR = "{ l.ok }">
		<MvPRIMARY NAME = "Attributes" INDEX = "{ g._DB_Store_Directory $ 'atr_at_i.mvx' }">

		<MvFIND NAME = "Attributes" VALUE = "{ l.attemp_id }">
		<MvIF EXPR = "{ NOT Attributes.d.EOF }">
			<MvFUNCTIONRETURN VALUE = "1">
		<MvELSE>
			<MvFUNCTIONRETURN VALUE = "0">
		</MvIF>
	</MvIF>

</MvFUNCTION>

<MvFUNCTION NAME = "AttributeTemplate_FindFirst" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.found" VALUE = "0">
	<MvIF EXPR = "{ _DB_Store_Open_AttributeTemplates() }">
		<MvPRIMARY NAME = "AttributeTemplates" INDEX = "{ g._DB_Store_Directory $ 'attemplc.mvx' }">
		<MvGO NAME = "AttributeTemplates" ROW = "top">

		<MvIF EXPR = "{ NOT AttributeTemplates.d.EOF }">
			<MvASSIGN NAME = "l.found" VALUE = "1">
		</MvIF>
	</MvIF>

	<MvFUNCTIONRETURN VALUE = "{ l.found }">
</MvFUNCTION>

<MvFUNCTION NAME = "AttributeTemplate_FindNext" PARAMETERS = "" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.found" VALUE = "1">
	<MvSKIP NAME = "AttributeTemplates" ROWS = "1">
	<MvIF EXPR = "{ AttributeTemplates.d.EOF }">
		<MvASSIGN NAME = "l.found" VALUE = "0">
	</MvIF>

	<MvFUNCTIONRETURN VALUE = "{ l.found }">
</MvFUNCTION>

<MvFUNCTION NAME = "AttributeTemplate_Copy" PARAMETERS = "template_id, product_id, nodups" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" value = "1">
		<MvASSIGN NAME = "l.attribute_found" VALUE = "{ AttributeTemplateAttribute_FindFirst_AttributeTemplate( l.template_id ) }">
		
		<MvWHILE EXPR = "{ l.attribute_found AND l.ok}">
			<MvASSIGN NAME = "l.code_suffix" VALUE = "">
			<MvASSIGN NAME = "l.attribute_code" VALUE = "{ AttributeTemplateAttributes.d.code $ l.code_suffix }">
			<MvDO FILE = "{ g.Module_Library_DB }" NAME = "l.code_found" VALUE = "{ Attribute_Find_Code( l.product_id, l.attribute_code ) }">

			<MvIF EXPR = "{ NOT l.nodups }">
				<MvWHILE EXPR = "{ l.code_found }">
					<MvASSIGN NAME = "l.code_suffix" VALUE = "{ l.code_suffix + 1 }">
					<MvASSIGN NAME = "l.attribute_code" VALUE = "{ AttributeTemplateAttributes.d.code $ l.code_suffix }">
					<MvDO FILE = "{ g.Module_Library_DB }" NAME = "l.code_found" VALUE = "{ Attribute_Find_Code( l.product_id, l.attribute_code ) }">
				</MvWHILE>
			</MvIF>
			<MvIF EXPR = "{ NOT l.code_found }">
				<MvDO FILE = "{ g.Module_Library_DB }" NAME = "l.attribute_id" VALUE = "{ Attribute_Insert( l.product_id, l.attribute_code, AttributeTemplateAttributes.d.type, 0, AttributeTemplateAttributes.d.prompt, AttributeTemplateAttributes.d.price, AttributeTemplateAttributes.d.cost, AttributeTemplateAttributes.d.required, AttributeTemplateAttributes.d.image ) }">
				<MvASSIGN NAME = "l.option_found" VALUE = "{ AttributeTemplateOption_FindFirst_Attribute( AttributeTemplateAttributes.d.id ) }">
				<MvWHILE EXPR = "{ l.option_found }">
					<MvDO FILE = "{ g.Module_Library_DB }" NAME = "l.ok" VALUE = "{ Option_Insert( l.attribute_id, AttributeTemplateOptions.d.code, AttributeTemplateOptions.d.prompt, AttributeTemplateOptions.d.price, AttributeTemplateOptions.d.cost, AttributeTemplateOptions.d.image ) }">
					<MvASSIGN NAME = "l.option_found" VALUE = "{ AttributeTemplateOption_FindNext_Attribute( AttributeTemplateAttributes.d.id ) }">
				</MvWHILE>
			</MvIF>
			<MvASSIGN NAME = "l.attribute_found" VALUE = "{ AttributeTemplateAttribute_FindNext_AttributeTemplate( l.template_id ) }">
		</MvWHILE>
	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvCOMMENT>
|
|	Attribute Template Attributes
|
</MvCOMMENT>

<MvFUNCTION NAME = "_DB_Store_Open_AttributeTemplateAttributes" STANDARDOUTPUTLEVEL = "" ERROROUTPUTLEVEL = "syntax, expression">
	<MvASSIGN NAME = "l.ok" VALUE = "1">

	<MvIF EXPR = "{ NOT g._DB_Store_AttributeTemplateAttributes_Open }">
		<MvOPEN NAME = "AttributeTemplateAttributes" 
				DATABASE = "{ g._DB_Store_Directory $ 'atmpatt.dbf' }" 
				INDEXES = "{ g._DB_Store_Directory $ 'atmpatti.mvx,' $ g._DB_Store_Directory $ 'atmpattc.mvx,' $ g._DB_Store_Directory $ 'atmpatta.mvx' }">
		<MvIF EXPR = "{ MvOPEN_Error }">
			<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-ATT-DTB-00028', MvOPEN_Error ) }">
		<MvELSE>
			<MvASSIGN NAME = "g._DB_Store_AttributeTemplateAttributes_Open" VALUE = "1">
			<MvFILTER NAME = "AttributeTemplateAttributes" FILTER = "{ NOT AttributeTemplateAttributes.d.deleted }">
		</MvIF>
	</MvIF>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "AttributeTemplateAttribute_Find_Code" PARAMETERS = "template_id, code" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.attribute_id" VALUE = "0">
	<MvIF EXPR = "{ _DB_Store_Open_AttributeTemplateAttributes() }">
		<MvPRIMARY NAME = "AttributeTemplateAttributes" INDEX = "{ g._DB_Store_Directory $ 'atmpattc.mvx' }">

		<MvFIND NAME = "AttributeTemplateAttributes" VALUE = "{ l.template_id $ ':' $ toupper( l.code ) }" EXACT>
		<MvIF EXPR = "{ AttributeTemplateAttributes.d.EOF }">
			<MvLOCALIZED NAME = "l.error"  ID = "MER-ATT-DTB-00003">
				<MvLOCALIZED-TOKEN NAME = "template" VALUE = "{ encodeentities( template_id ) }">
				<MvLOCALIZED-TOKEN NAME = "code" VALUE = "{ encodeentities( l.code ) }">
				<MvLOCALIZED-TEXT LANGUAGE = "en-US">Attribute Template Attribute '%template%:%code%' not found</MvLOCALIZED-TEXT>
			</MvLOCALIZED>

			<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-ATT-00004', l.error ) }">
		<MvELSE>
			<MvASSIGN NAME = "l.attribute_id" VALUE = "{ AttributeTemplateAttributes.d.id }">
		</MvIF>
	</MvIF>

	<MvFUNCTIONRETURN VALUE = "{ l.attribute_id }">
</MvFUNCTION>

<MvFUNCTION NAME = "AttributeTemplateAttribute_Delete" PARAMETERS = "id" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = "{ _DB_Store_Open_AttributeTemplateAttributes() }">
	
	<MvIF EXPR = "{ l.ok }">
		<MvASSIGN NAME = "l.ok" VALUE = "{ _DB_Store_Open_AttributeTemplateOptions() }">
	</MvIF>

	<MvIF EXPR = "{ l.ok }">
		<MvPRIMARY NAME = "AttributeTemplateAttributes" INDEX = "{ g._DB_Store_Directory $ 'atmpatti.mvx' }">
		<MvPRIMARY NAME = "AttributeTemplateOptions" INDEX = "{ g._DB_Store_Directory $ 'attmpopa.mvx' }">

		<MvFIND NAME = "AttributeTemplateAttributes" VALUE = "{ l.id }" EXACT>
		<MvIF EXPR = "{ AttributeTemplateAttributes.d.EOF }">
			<MvLOCALIZED NAME = "l.error" ID = "MER-ATT-DTB-00004">
				<MvLOCALIZED-TOKEN NAME = "id" VALUE = "{ encodeentities( l.id ) }">
				<MvLOCALIZED-TEXT LANGUAGE = "en-US">AttributeTemplateAttribute '%id%' not found</MvLOCALIZED-TEXT>
			</MvLOCALIZED>

			<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-ATT-DTB-00005', l.error ) }">
		<MvELSE>
			<MvFIND NAME = "AttributeTemplateOptions" VALUE = "{ l.id $ ':' }">
			<MvWHILE EXPR = "{ ( NOT AttributeTemplateOptions.d.EOF ) AND ( AttributeTemplateOptions.d.attr_id EQ l.id ) }">
				<MvDELETE NAME = "AttributeTemplateOptions">
				<MvSKIP NAME = "AttributeTemplateOptions" ROWS = "1">
			</MvWHILE>

			<MvDELETE NAME = "AttributeTemplateAttributes">
		</MvIF>
	</MvIF>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "AttributeTemplateAttribute_FindFirst_AttributeTemplate" PARAMETERS = "template_id" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.found" VALUE = "0">
	<MvIF EXPR = "{ _DB_Store_Open_AttributeTemplateAttributes() }">
		<MvPRIMARY NAME = "AttributeTemplateAttributes" INDEX = "{ g._DB_Store_Directory $ 'atmpatta.mvx' }">
		<MvFIND NAME = "AttributeTemplateAttributes" VALUE = "{ l.template_id $ ':' }">
		<MvIF EXPR = "{ NOT AttributeTemplateAttributes.d.EOF }">
			<MvASSIGN NAME = "l.found" VALUE = "1">
		</MvIF>
	</MvIF>

	<MvFUNCTIONRETURN VALUE = "{ l.found }">		
</MvFUNCTION>

<MvFUNCTION NAME = "AttributeTemplateAttribute_FindNext_AttributeTemplate" PARAMETERS = "template_id" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.found" VALUE = "1">
	<MvSKIP NAME = "AttributeTemplateAttributes" ROWS = "1">
	<MvIF EXPR = "{ ( AttributeTemplateAttributes.d.EOF ) OR ( AttributeTemplateAttributes.d.attemp_id NE l.template_id ) }">
		<MvASSIGN NAME = "l.found" VALUE = "0">
	</MvIF>

	<MvFUNCTIONRETURN VALUE = "{ l.found }">
</MvFUNCTION>

<MvFUNCTION NAME = "AttributeTemplates_FindFirst" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.found" VALUE = "0">
	<MvIF EXPR = "{ _DB_Store_Open_AttributeTemplates() }">
		<MvPRIMARY NAME = "AttributeTemplates" INDEX = "{ g._DB_Store_Directory $ 'attemplc.mvx' }">
		<MvGO NAME = "AttributeTemplates" ROW = "top">
		<MvIF EXPR = "{ NOT AttributeTemplates.d.EOF }">
			<MvASSIGN NAME = "l.found" VALUE = "1">
		</MvIF>
	</MvIF>

	<MvFUNCTIONRETURN VALUE = "{ l.found }">
</MvFUNCTION>

<MvFUNCTION NAME = "AttributeTemplates_FindFirst_Offset" PARAMETERS = "offset" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.found" VALUE = "0">
	<MvIF EXPR = "{ _DB_Store_Open_AttributeTemplates() }">
		<MvPRIMARY NAME = "AttributeTemplates" INDEX = "{ g._DB_Store_Directory $ 'attemplc.mvx' }">
		<MvGO NAME = "AttributeTemplates" ROW = "top">
		<MvSKIP NAME = "AttributeTemplates" ROWS = "{ l.offset }">
		<MvIF EXPR = "{ NOT AttributeTemplates.d.EOF }">
			<MvASSIGN NAME = "l.found" VALUE = "1">
		</MvIF>
	</MvIF>

	<MvFUNCTIONRETURN VALUE = "{ l.found }">
</MvFUNCTION>

<MvFUNCTION NAME = "AttributeTemplates_FindNext" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.found" VALUE = "1">

	<MvSKIP NAME = "AttributeTemplates" ROWS = "1">
	<MvIF EXPR = "{ AttributeTemplates.d.EOF }">
		<MvASSIGN NAME = "l.found" VALUE = "0">
	</MvIF>

	<MvFUNCTIONRETURN VALUE = "{ l.found }">
</MvFUNCTION>

<MvFUNCTION NAME = "AttributeTemplates_FindOffset_All" PARAMETERS = "offset, search" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.found" VALUE = "0">
	<MvASSIGN NAME = "l.newoffset" VALUE = "{ l.offset + 1 }">

	<MvIF EXPR = "{ _DB_Store_Open_AttributeTemplates() }">
		<MvPRIMARY NAME = "AttributeTemplates" INDEX = "{ g._DB_Store_Directory $ 'attemplc.mvx' }">
		<MvASSIGN NAME = "l.filter" VALUE = "{ _AttributeTemplates_Filter( l.search ) }">
		<MvFILTER NAME = "AttributeTemplates" FILTER = "l.filter" FILTER_TYPE = "variable">

		<MvSKIP NAME = "AttributeTemplates" ROWS = "{ l.offset }">
		<MvIF EXPR = "{ NOT AttributeTemplates.d.EOF }">
			<MvASSIGN NAME = "l.found" VALUE = "1">
		</MvIF>
	</MvIF>

	<MvIF EXPR = "{ l.found }">
		<MvFUNCTIONRETURN VALUE = "{ l.newoffset }">
	<MvELSE>
		<MvFUNCTIONRETURN VALUE = "0">
	</MvIF>
</MvFUNCTION>

<MvFUNCTION NAME = "AttributeTemplates_FindNext_All" PARAMETERS = "offset, search" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.found" VALUE = "0">
	<MvASSIGN NAME = "l.newoffset" VALUE = "{ l.offset + 1 }">

	<MvSKIP NAME = "AttributeTemplates" ROWS = "1">
	<MvIF EXPR = "{ NOT AttributeTemplates.d.EOF }">
		<MvASSIGN NAME = "l.found" VALUE = "1">
	</MvIF>

	<MvIF EXPR = "{ l.found }">
		<MvFUNCTIONRETURN VALUE = "{ l.newoffset }">
	<MvELSE>
		<MvFILTER NAME = "AttributeTemplates" FILTER = "{ NOT AttributeTemplates.d.deleted }">
		<MvFUNCTIONRETURN VALUE = "0">
	</MvIF>
</MvFUNCTION>

<MvFUNCTION NAME = "AttributeTemplateAttribute_Insert" PARAMETERS = "template_id, code, type, prompt, price, cost, required, image" STANDARDOUTPUTLEVEL = "">

	<MvASSIGN NAME = "l.attribute_id" VALUE = "0">
	<MvIF EXPR = "{ _DB_Store_Open_AttributeTemplateAttributes() }">

		<MvDO FILE = "{ g.Module_Library_DB }" NAME = "l.key" VALUE = "{ StoreKey_Generate( 'AttributeTemplateAttributes' ) }">

		<MvASSIGN NAME = "AttributeTemplateAttributes.d.id" VALUE = "{ l.key }">
		<MvASSIGN NAME = "AttributeTemplateAttributes.d.attemp_id" VALUE = "{ l.template_id }">
		<MvASSIGN NAME = "AttributeTemplateAttributes.d.default_id" VALUE = "0">
		<MvASSIGN NAME = "AttributeTemplateAttributes.d.order" VALUE = "{ AttributeTemplateAttributes.d.id }">
		<MvASSIGN NAME = "AttributeTemplateAttributes.d.code" VALUE = "{ ltrim( rtrim( l.code ) ) }">
		<MvASSIGN NAME = "AttributeTemplateAttributes.d.type" VALUE = "{ l.type }">
		<MvASSIGN NAME = "AttributeTemplateAttributes.d.prompt" VALUE = "{ l.prompt }">
		<MvASSIGN NAME = "AttributeTemplateAttributes.d.price" VALUE = "{ l.price }">
		<MvASSIGN NAME = "AttributeTemplateAttributes.d.cost" VALUE = "{ l.cost }">
		<MvASSIGN NAME = "AttributeTemplateAttributes.d.required" VALUE = "{ l.required }">
		<MvASSIGN NAME = "AttributeTemplateAttributes.d.image" VALUE = "{ l.image }">
		
		<MvADD NAME = "AttributeTemplateAttributes">

		<MvASSIGN NAME = "l.attribute_id" VALUE = "{ AttributeTemplateAttributes.d.id }">
	</MvIF>

	<MvFUNCTIONRETURN VALUE = "{ l.attribute_id }">
</MvFUNCTION>


<MvFUNCTION NAME = "AttributeTemplateAttribute_Update_Order" PARAMETERS = "id, order" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = "{ _DB_Store_Open_AttributeTemplateAttributes() }">

	<MvIF EXPR = "{ l.ok }">
		<MvPRIMARY NAME = "AttributeTemplateAttributes" INDEX = "{ g._DB_Store_Directory $ 'atmpatti.mvx' }">

		<MvFIND NAME = "AttributeTemplateAttributes" VALUE = "{ l.id }" EXACT>
		<MvIF EXPR = "{ AttributeTemplateAttributes.d.EOF }">
			<MvLOCALIZED NAME = "l.error" ID = "MER-ATT-DTB-00005">
				<MvLOCALIZED-TOKEN NAME = "id" VALUE = "{ encodeentities( l.id ) }">
				<MvLOCALIZED-TEXT LANGUAGE = "en-US">AttributeTemplateAttributes '%id%' not found</MvLOCALIZED-TEXT>
			</MvLOCALIZED>

			<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-ATT-DTB-00006', l.error ) }">
		<MvELSE>
			<MvASSIGN NAME = "AttributeTemplateAttributes.d.order" VALUE = "{ l.order }">
			<MvUPDATE NAME = "AttributeTemplateAttributes">
		</MvIF>
	</MvIF>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "AttributeTemplateAttribute_Update" PARAMETERS = "id, default_id, code, type, prompt, price, cost, required, image" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = "{ _DB_Store_Open_AttributeTemplateAttributes() }">

	<MvIF EXPR = "{ l.ok }">
		<MvPRIMARY NAME = "AttributeTemplateAttributes" INDEX = "{ g._DB_Store_Directory $ 'atmpatti.mvx' }">

		<MvFIND NAME = "AttributeTemplateAttributes" VALUE = "{ l.id }" EXACT>
		<MvIF EXPR = "{ AttributeTemplateAttributes.d.EOF }">
			<MvLOCALIZED NAME = "l.error" ID = "MER-ATT-DTB-00006">
				<MvLOCALIZED-TOKEN NAME = "id" VALUE = "{ encodeentities( l.id ) }">
				<MvLOCALIZED-TEXT LANGUAGE = "en-US">Attribute '%id%' not found</MvLOCALIZED-TEXT>
			</MvLOCALIZED>

			<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-ATT-DTB-00007', l.error ) }">
		<MvELSE>
			<MvASSIGN NAME = "AttributeTemplateAttributes.d.default_id" VALUE = "{ l.default_id }">
			<MvASSIGN NAME = "AttributeTemplateAttributes.d.code" VALUE = "{ ltrim( rtrim( l.code ) ) }">
			<MvASSIGN NAME = "AttributeTemplateAttributes.d.type" VALUE = "{ l.type }">
			<MvASSIGN NAME = "AttributeTemplateAttributes.d.prompt" VALUE = "{ l.prompt }">
			<MvASSIGN NAME = "AttributeTemplateAttributes.d.price" VALUE = "{ l.price }">
			<MvASSIGN NAME = "AttributeTemplateAttributes.d.cost" VALUE = "{ l.cost }">
			<MvASSIGN NAME = "AttributeTemplateAttributes.d.required" VALUE = "{ l.required }">
			<MvASSIGN NAME = "AttributeTemplateAttributes.d.image" VALUE = "{ l.image }">
			<MvUPDATE NAME = "AttributeTemplateAttributes">
		</MvIF>
	</MvIF>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvCOMMENT>
|
|	AttributeTemplateOptions
|
</MvCOMMENT>

<MvFUNCTION NAME = "_DB_Store_Open_AttributeTemplateOptions" STANDARDOUTPUTLEVEL = "" ERROROUTPUTLEVEL = "syntax, expression">
	<MvASSIGN NAME = "l.ok" VALUE = "1">

	<MvIF EXPR = "{ NOT g._DB_Store_AttributeTemplateOptions_Open }">
		<MvOPEN NAME = "AttributeTemplateOptions" 
				DATABASE = "{ g._DB_Store_Directory $ 'attmpop.dbf' }"
				INDEXES = "{ g._DB_Store_Directory $ 'attmpopi.mvx, ' $ g._DB_Store_Directory $ 'attmpopc.mvx, ' $ g._DB_Store_Directory $ 'attmpopa.mvx' }">
		<MvIF EXPR = "{ MvOPEN_Error }">
			<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-ATT-DTB-00008', MvOPEN_Error ) }">
		<MvELSE>
			<MvASSIGN NAME = "g._DB_Store_AttributeTemplateOptions_Open" VALUE = "1">
			<MvFILTER NAME = "AttributeTemplateOptions" FILTER = "{ NOT AttributeTemplateOptions.d.deleted }">
		</MvIF>
	</MvIF>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "AttributeTemplateOption_Insert" PARAMETERS = "attmpat_id, code, prompt, price, cost, image" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.option_id" VALUE = "0">
	<MvIF EXPR = "{ _DB_Store_Open_AttributeTemplateOptions() }">

		<MvDO FILE = "{ g.Module_Library_DB }" NAME = "l.key" VALUE = "{ StoreKey_Generate( 'AttributeTemplateOptions' ) }">

		<MvASSIGN NAME = "AttributeTemplateOptions.d.id" VALUE = "{ l.key }">
		<MvASSIGN NAME = "AttributeTemplateOptions.d.attmpat_id" VALUE = "{ l.attmpat_id }">
		<MvASSIGN NAME = "AttributeTemplateOptions.d.order" VALUE = "{ AttributeTemplateOptions.d.id }">
		<MvASSIGN NAME = "AttributeTemplateOptions.d.code" VALUE = "{ ltrim( rtrim( l.code ) ) }">
		<MvASSIGN NAME = "AttributeTemplateOptions.d.prompt" VALUE = "{ l.prompt }">
		<MvASSIGN NAME = "AttributeTemplateOptions.d.price" VALUE = "{ l.price }">
		<MvASSIGN NAME = "AttributeTemplateOptions.d.cost" VALUE = "{ l.cost }">
		<MvASSIGN NAME = "AttributeTemplateOptions.d.image" VALUE = "{ l.image }">

		<MvADD NAME = "AttributeTemplateOptions">
		<MvASSIGN NAME = "l.option_id" VALUE = "{ AttributeTemplateOptions.d.id }">
	</MvIF>

	<MvFUNCTIONRETURN VALUE = "{ l.option_id }">
</MvFUNCTION>

<MvFUNCTION NAME = "AttributeTemplateOption_Update" PARAMETERS = "id, code, prompt, price, cost, image" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = "{ _DB_Store_Open_AttributeTemplateOptions() }">

	<MvIF EXPR = "{ l.ok }">
		<MvPRIMARY NAME = "AttributeTemplateOptions" INDEX = "{ g._DB_Store_Directory $ 'attmpopi.mvx' }">

		<MvFIND NAME = "AttributeTemplateOptions" VALUE = "{ l.id }" EXACT>
		<MvIF EXPR = "{ AttributeTemplateOptions.d.EOF }">
			<MvLOCALIZED NAME = "l.error" ID = "MER-ATT-DTB-00007">
				<MvLOCALIZED-TOKEN NAME = "id" VALUE = "{ encodeentities( l.id ) }">
				<MvLOCALIZED-TEXT LANGUAGE = "en-US">AttributeTemplateOption '%id%' not found</MvLOCALIZED-TEXT>
			</MvLOCALIZED>

			<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-ATT-DTB-00009', l.error ) }">
		<MvELSE>
			<MvASSIGN NAME = "AttributeTemplateOptions.d.code" VALUE = "{ ltrim( rtrim( l.code ) ) }">
			<MvASSIGN NAME = "AttributeTemplateOptions.d.prompt" VALUE = "{ l.prompt }">
			<MvASSIGN NAME = "AttributeTemplateOptions.d.price" VALUE = "{ l.price }">
			<MvASSIGN NAME = "AttributeTemplateOptions.d.cost" VALUE = "{ l.cost }">
			<MvASSIGN NAME = "AttributeTemplateOptions.d.image" VALUE = "{ l.image }">

			<MvUPDATE NAME = "AttributeTemplateOptions">
		</MvIF>
	</MvIF>
		
	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "AttributeTemplateOption_Update_Order" PARAMETERS = "id, order" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = "{ _DB_Store_Open_AttributeTemplateOptions() }">

	<MvIF EXPR = "{ l.ok }">
		<MvPRIMARY NAME = "AttributeTemplateOptions" INDEX = "{ g._DB_Store_Directory $ 'attmpopi.mvx' }">
		
		<MvFIND NAME = "AttributeTemplateOptions" VALUE = "{ l.id }" EXACT>
		<MvIF EXPR = "{ AttributeTemplateOptions.d.EOF }">
			<MvLOCALIZED NAME = "l.error" ID = "MER-ATT-DTB-00008">
				<MvLOCALIZED-TOKEN NAME = "id" VALUE = "{ encodeentities( l.id ) }">
				<MvLOCALIZED-TEXT LANGUAGE = "en-US">AttributeTemplateOption '%id%' not found</MvLOCALIZED-TEXT>
			</MvLOCALIZED>

			<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-ATT-DTB-00010', l.error ) }">
		<MvELSE>
			<MvASSIGN NAME = "AttributeTemplateOptions.d.order" VALUE = "{ l.order }">
			<MvUPDATE NAME = "AttributeTemplateOptions">
		</MvIF>
	</MvIF>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "AttributeTemplateOption_Delete" PARAMETERS = "id" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = "{ _DB_Store_Open_AttributeTemplateOptions() }">
	<MvIF EXPR = "{ l.ok }">
		<MvPRIMARY NAME = "AttributeTemplateOptions" INDEX = "{ g._DB_Store_Directory $ 'attmpopi.mvx' }">
		
		<MvFIND NAME = "AttributeTemplateOptions" VALUE = "{ l.id }" EXACT>
		<MvIF EXPR = "{ AttributeTemplateOptions.d.EOF }">
			<MvLOCALIZED NAME = "l.error" ID = "MER-ATT-DTB-00009">
				<MvLOCALIZED-TOKEN NAME = "id" VALUE = "{ encodeentities( l.id ) }">
				<MvLOCALIZED-TEXT LANGUAGE = "en-US">AttributeTemplateOption '%id%' not found</MvLOCALIZED-TEXT>
			</MvLOCALIZED>

			<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-ATT-DTB-00011', l.error ) }">
		<MvELSE>
			<MvDELETE NAME = "AttributeTemplateOptions">
		</MvIF>
	</MvIF>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "AttributeTemplateOption_Find_ID" PARAMETERS = "id" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.found" VALUE = "0">
	<MvIF EXPR = "{ _DB_Store_Open_AttributeTemplateOptions() }">
		<MvPRIMARY NAME = "AttributeTemplateOptions" INDEX = "{ g._DB_Store_Directory $ 'attmpopi.mvx' }">
		
		<MvFIND NAME = "AttributeTemplateOptions" VALUE = "{ l.id }" EXACT>
		<MvIF EXPR = "{ NOT AttributeTemplateOptions.d.EOF }">
			<MvASSIGN NAME = "l.found" VALUE = "1">
		<MvELSE>
			<MvLOCALIZED NAME = "l.error" ID = "MER-ATT-DTB-00010">
				<MvLOCALIZED-TOKEN NAME = "id" VALUE = "{ encodeentities( l.id ) }">
				<MvLOCALIZED-TEXT LANGUAGE = "en-US">AttributeTemplateOption '%id%' not found</MvLOCALIZED-TEXT>
			</MvLOCALIZED>

			<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-ATT-DTB-00012', l.error ) }">
		</MvIF>
	</MvIF>

	<MvFUNCTIONRETURN VALUE = "{ l.found }">
</MvFUNCTION>

<MvFUNCTION NAME = "AttributeTemplateOption_Find_Code" PARAMETERS = "attr_id, code" STANDARDOUTPUTLEVEL = "">

	<MvASSIGN NAME = "l.option_id" VALUE = "0">
	<MvIF EXPR = "{ _DB_Store_Open_AttributeTemplateOptions() }">
		<MvPRIMARY NAME = "AttributeTemplateOptions" INDEX = "{ g._DB_Store_Directory $ 'attmpopc.mvx' }">

		<MvFIND NAME = "AttributeTemplateOptions" VALUE = "{ l.attr_id $ ':' $ toupper( l.code ) }" EXACT>
		<MvIF EXPR = "{ AttributeTemplateOptions.d.EOF }">
			<MvLOCALIZED NAME = "l.error" ID = "MER-ATT-DTB-00011">
				<MvLOCALIZED-TOKEN NAME = "code" VALUE = "{ encodeentities( l.code ) }">
				<MvLOCALIZED-TEXT LANGUAGE = "en-US">AttributeTemplateOption '%code%' not found</MvLOCALIZED-TEXT>
			</MvLOCALIZED>

			<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-ATT-DTB-00013', l.error ) }">
		<MvELSE>
			<MvASSIGN NAME = "l.option_id" VALUE = "{ AttributeTemplateOptions.d.id }">
		</MvIF>
	</MvIF>

	<MvFUNCTIONRETURN VALUE = "{ l.option_id }">
</MvFUNCTION>

<MvFUNCTION NAME = "AttributeTemplateOption_FindFirst_Attribute" PARAMETERS = "attr_id" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.found" VALUE = "0">
	<MvIF EXPR = "{ _DB_Store_Open_AttributeTemplateOptions() }">
		<MvPRIMARY NAME = "AttributeTemplateOptions" INDEX = "{ g._DB_Store_Directory $ 'attmpopa.mvx' }">
		<MvFIND NAME = "AttributeTemplateOptions" VALUE = "{ l.attr_id $ ':' }">
		<MvIF EXPR = "{ NOT AttributeTemplateOptions.d.EOF }">
			<MvASSIGN NAME = "l.found" VALUE = "1">
		</MvIF>
	</MvIF>

	<MvFUNCTIONRETURN VALUE = "{ l.found }">
</MvFUNCTION>

<MvFUNCTION NAME = "AttributeTemplateOption_FindNext_Attribute" PARAMETERS = "attr_id" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.found" VALUE = "1">
	
	<MvSKIP NAME = "AttributeTemplateOptions" ROWS = "1">
	<MvIF EXPR = "{ ( AttributeTemplateOptions.d.EOF ) OR ( AttributeTemplateOptions.d.attmpat_id NE l.attr_id ) }">
		<MvASSIGN NAME = "l.found" VALUE = "0">
	</MvIF>

	<MvFUNCTIONRETURN VALUE = "{ l.found }">
</MvFUNCTION>

<MvFUNCTION NAME = "Attribute_FindFirst_ProductTemplate" PARAMETERS = "product_id, template_id" STANDARDOUTPUTLEVEL = "" ERROROUTPUTLEVEL = "syntax, expression, runtime">
	<MvASSIGN NAME = "l.found" VALUE = "0">
	<MvDO FILE = "{ g.Module_Library_DB }" NAME = "l.ok" VALUE = "{ _DB_Store_Open_Attributes() }">
	
	<MvIF EXPR = "{ l.ok }">
		<MvPRIMARY NAME = "Attributes" INDEX = "{ g._DB_Store_Directory $ 'atr_at_p.mvx' }">
		<MvFIND NAME = "Attributes" VALUE = "{ l.product_id $ ':' $ padl( template_id, 10, '0') $ ':'}">
		<MvIF EXPR = "{ NOT Attributes.d.EOF }">
			<MvASSIGN NAME = "l.found" VALUE = "1">
		</MvIF>
	</MvIF>
		
	<MvFUNCTIONRETURN VALUE = "{ l.found }">		
</MvFUNCTION>

<MvFUNCTION NAME = "ATT_Store_Create" STANDARDOUTPUTLEVEL = "" ERROROUTPUTLEVEL = "syntax, expression">
	<MvASSIGN NAME = "l.ok" VALUE = 1>
	<MvCREATE NAME = "AttributeTemplates"
			  DATABASE = "{ g._DB_Store_Directory $ 'attempl.dbf' }"
			  FIELDS = "id			NUMBER,
						code		CHAR( 50 ),
						prompt		CHAR( 50 ),
						refcount	NUMBER">
	<MvIF EXPR = "{ MvCREATE_Error }">
		<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-ATT-DTB-00014', MvCREATE_Error ) }">
	<MvELSE>
		<MvASSIGN NAME = "g._DB_Store_AttributeTemplates_Open" VALUE = "1">
	</MvIF>

	<MvIF EXPR = "{ l.ok }">
		<MvMAKEINDEX NAME = "AttributeTemplates"
					 INDEXFILE = "{ g._DB_Store_Directory $ 'attempli.mvx' }"
					 EXPRESSION = "{ AttributeTemplates.d.id }"
					 FLAGS = "nounique, ascending">
		<MvIF EXPR = "{ MvMAKEINDEX_Error }">
			<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-ATT-DTB-00015', MvMAKEINDEX_Error ) }">
		</MvIF>
	</MvIF>

	<MvIF EXPR = "{ l.ok }">
		<MvMAKEINDEX NAME = "AttributeTemplates"
					 INDEXFILE = "{ g._DB_Store_Directory $ 'attemplc.mvx' }"
					 EXPRESSION = "{ toupper( AttributeTemplates.d.code ) }"
					 FLAGS = "nounique, ascending">
		<MvIF EXPR = "{ MvMAKEINDEX_Error }">
			<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-ATT-DTB-00016', MvMAKEINDEX_Error ) }">
		</MvIF>
	</MvIF>

	<MvIF EXPR = "{ l.ok }">
		<MvCLOSE NAME = "AttributeTemplates">
		<MvASSIGN NAME = "g._DB_Store_AttributeTemplates_Open" VALUE = "0">
	</MvIF>
	
	<MvIF EXPR = "{ l.ok }">
		<MvCREATE NAME = "AttributeTemplateAttributes"
				  DATABASE = "{ g._DB_Store_Directory $ 'atmpatt.dbf' }"
				  FIELDS = "id			NUMBER,
							attemp_id	NUMBER,
							default_id	NUMBER,
							order		NUMBER,
							code		CHAR( 50 ),
							type		CHAR( 20 ),
							prompt		MEMO,
							price		NUMBER( 10.2 ),
							cost		NUMBER( 10.2 ),
							required	BOOL,
							image		CHAR( 254 )">
		<MvIF EXPR = "{ MvCREATE_Error }">
			<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-ATT-DTB-00017', MvCREATE_Error ) }">
		<MvELSE>
			<MvASSIGN NAME = "g._DB_Store_AttributeTemplateAttributes_Open" VALUE = "1">
		</MvIF>
	
		<MvIF EXPR = "{ l.ok }">
			<MvMAKEINDEX NAME = "AttributeTemplateAttributes"
						 INDEXFILE = "{ g._DB_Store_Directory $ 'atmpatti.mvx' }"
						 EXPRESSION = "{ AttributeTemplateAttributes.d.id }"
						 FLAGS = "unique, ascending">
			<MvIF EXPR = "{ MvMAKEINDEX_Error }">
				<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-ATT-DTB-00018', MvMAKEINDEX_Error ) }">
			</MvIF>
		</MvIF>
	
		<MvIF EXPR = "{ l.ok }">
			<MvMAKEINDEX NAME = "AttributeTemplateAttributes"
						 INDEXFILE = "{ g._DB_Store_Directory $ 'atmpattc.mvx' }"
						 EXPRESSION = "{ AttributeTemplateAttributes.d.attemp_id $ ':' $ toupper( AttributeTemplateAttributes.d.code ) }"
						 FLAGS = "nounique, ascending">
			<MvIF EXPR = "{ MvMAKEINDEX_Error }">
				<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-ATT-DTB-00019', MvMAKEINDEX_Error ) }">
			</MvIF>
		</MvIF>
	
		<MvIF EXPR = "{ l.ok }">
			<MvMAKEINDEX NAME = "AttributeTemplateAttributes"
						 INDEXFILE = "{ g._DB_Store_Directory $ 'atmpatta.mvx' }"
						 EXPRESSION = "{ AttributeTemplateAttributes.d.attemp_id $ ':' $ padl( AttributeTemplateAttributes.d.order, 10, '0' ) }"
						 FLAGS = "nounique, ascending">
			<MvIF EXPR = "{ MvMAKEINDEX_Error }">
				<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-ATT-DTB-00020', MvMAKEINDEX_Error ) }">
			</MvIF>
		</MvIF>
	
		<MvIF EXPR = "{ l.ok }">
			<MvCLOSE NAME = "AttributeTemplateAttributes">
			<MvASSIGN NAME = "g._DB_Store_AttributeTemplateAttributes_Open" VALUE = "0">
		</MvIF>
	</MvIF>
	
	<MvIF EXPR = "{ l.ok }">
		<MvCREATE NAME = "AttributeTemplateOptions"
				  DATABASE = "{ g._DB_Store_Directory $ 'attmpop.dbf' }"
				  FIELDS = "id			NUMBER,
							attmpat_id	NUMBER,
							order		NUMBER,
							code		CHAR( 50 ),
							prompt		MEMO,
							price		NUMBER( 10.2 ),
							cost		NUMBER( 10.2 ),
							image		CHAR( 254 )">
		<MvIF EXPR = "{ MvCREATE_Error }">
			<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-ATT-DTB-00021', MvCREATE_Error ) }">
		<MvELSE>
			<MvASSIGN NAME = "g._DB_Store_AttributeTemplateOptions_Open" VALUE = "1">
		</MvIF>
	
		<MvIF EXPR = "{ l.ok }">
			<MvMAKEINDEX NAME = "AttributeTemplateOptions"
						 INDEXFILE = "{ g._DB_Store_Directory $ 'attmpopi.mvx' }"
						 EXPRESSION = "{ AttributeTemplateOptions.d.id }"
						 FLAGS = "unique, ascending">
			<MvIF EXPR = "{ MvMAKEINDEX_Error }">
				<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-ATT-DTB-00022', MvMAKEINDEX_Error ) }">
			</MvIF>
		</MvIF>
	
		<MvIF EXPR = "{ l.ok }">
			<MvMAKEINDEX NAME = "AttributeTemplateOptions"
						 INDEXFILE = "{ g._DB_Store_Directory $ 'attmpopc.mvx' }"
						 EXPRESSION = "{ AttributeTemplateOptions.d.attmpat_id $ ':' $ toupper( AttributeTemplateOptions.d.code ) }"
						 FLAGS = "nounique, ascending">
			<MvIF EXPR = "{ MvMAKEINDEX_Error }">
				<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-ATT-DTB-00023', MvMAKEINDEX_Error ) }">
			</MvIF>
		</MvIF>
	
		<MvIF EXPR = "{ l.ok }">
			<MvMAKEINDEX NAME = "AttributeTemplateOptions"
						 INDEXFILE = "{ g._DB_Store_Directory $ 'attmpopa.mvx' }"
						 EXPRESSION = "{ AttributeTemplateOptions.d.attmpat_id $ ':' $ padl( AttributeTemplateOptions.d.order, 10, '0' ) }"
						 FLAGS = "nounique, ascending">
			<MvIF EXPR = "{ MvMAKEINDEX_Error }">
				<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-ATT-DTB-00024', MvMAKEINDEX_Error ) }">
			</MvIF>
		</MvIF>
	
		<MvIF EXPR = "{ l.ok }">
			<MvCLOSE NAME = "AttributeTemplateOptions">
			<MvASSIGN NAME = "g._DB_Store_AttributeTemplateOptions_Open" VALUE = "0">
		</MvIF>
	</MvIF>
	
	<MvDO FILE = "{ g.Module_Library_DB }" NAME = "l.ok" VALUE = "{ StoreKey_Insert( 'AttributeTemplates', 1 ) }">
	<MvDO FILE = "{ g.Module_Library_DB }" NAME = "l.ok" VALUE = "{ StoreKey_Insert( 'AttributeTemplateOptions', 1 ) }">
	<MvDO FILE = "{ g.Module_Library_DB }" NAME = "l.ok" VALUE = "{ StoreKey_Insert( 'AttributeTemplateAttributes', 1 ) }">

	
	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

