<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/cus/cus_db.mv,v $
|
| Prefix         : MER-CUS-DB-
| Next Error Code: 0    
| Next Text ID   : 6    
|
</MvCOMMENT>

<MvCOMMENT>
|
| Customers 
|
</MvCOMMENT>

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

	<MvLOCALIZED NAME = "l.privilege" ID = "MER-CUS-DB-00000">
		<MvLOCALIZED-TEXT LANGUAGE = "en-US">Customer</MvLOCALIZED-TEXT>
	</MvLOCALIZED>
	<MvDO FILE = "{ g.Module_Library_DB }" NAME = "l.ok" VALUE = "{ Privilege_Insert( 'CUST', l.privilege ) }">
	
	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "CUS_Store_Create">
	<MvASSIGN NAME = "l.ok" VALUE = 1>
	<MvCREATE NAME = "Customers"
			  DATABASE = "{ g._DB_Store_Directory $ 'customer.dbf' }"
			  FIELDS = "id			NUMBER,
						pgrpcount	NUMBER,
						login		CHAR( 50 ),
						pw_email	CHAR( 50 ),
						password	CHAR( 40 ),
						ship_fname	CHAR( 50 ),
						ship_lname	CHAR( 50 ),
						ship_email	CHAR( 50 ),
						ship_comp	CHAR( 50 ),
						ship_phone	CHAR( 50 ),
						ship_fax	CHAR( 50 ),
						ship_addr	CHAR( 100 ),
						ship_city	CHAR( 50 ),
						ship_state	CHAR( 50 ),
						ship_zip	CHAR( 50 ),
						ship_cntry	CHAR( 50 ),
						bill_fname	CHAR( 50 ),
						bill_lname	CHAR( 50 ),
						bill_email	CHAR( 50 ),
						bill_comp	CHAR( 50 ),
						bill_phone	CHAR( 50 ),
						bill_fax	CHAR( 50 ),
						bill_addr	CHAR( 100 ),
						bill_city	CHAR( 50 ),
						bill_state	CHAR( 50 ),
						bill_zip	CHAR( 50 ),
						bill_cntry	CHAR( 50 )">
	<MvIF EXPR = "{ MvCREATE_Error }">
		<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-DTB-00200', MvCREATE_Error ) }">
	<MvELSE>
		<MvASSIGN NAME = "g._DB_Store_Customers_Open" VALUE = 1>
	</MvIF>

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

	<MvIF EXPR = "{ l.ok }">
		<MvMAKEINDEX NAME = "Customers"
					 INDEXFILE = "{ g._DB_Store_Directory $ 'cust_lgn.mvx' }"
					 EXPRESSION = "{ toupper( Customers.d.login ) }"
					 FLAGS = "nounique, string, ascending">
		<MvIF EXPR = "{ MvMAKEINDEX_Error }">
			<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-DTB-00202', MvMAKEINDEX_Error ) }">
		</MvIF>
	</MvIF>

	<MvIF EXPR = "{ l.ok }">
		<MvCLOSE NAME = "Customers">
		<MvASSIGN NAME = "g._DB_Store_Customers_Open" VALUE = 0>
	</MvIF>

	<MvIF EXPR = "{ l.ok }">
		<MvCREATE NAME = "CustomerEmail"
				  DATABASE = "{ g._DB_Store_Directory $ 'custeml.dbf' }"
				  FIELDS = "from		CHAR( 254 ),
							cc			CHAR( 254 ),
							subject		CHAR( 254 ),
							header   	MEMO">
		<MvIF EXPR = "{ MvCREATE_Error }">
			<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-DTB-00203', MvCREATE_Error ) }">
		<MvELSE>
			<MvASSIGN NAME = "g._DB_Store_CustomerEmail_Open" VALUE = 1>

			<MvASSIGN NAME = "CustomerEmail.d.from" VALUE = "{ Stores.d.email }">
			<MvASSIGN NAME = "CustomerEmail.d.cc"   VALUE = "">

			<MvLOCALIZED NAME = "CustomerEmail.d.subject" ID = "MER-CUS-DB-00001">
				<MvLOCALIZED-TOKEN NAME = "store_name" VALUE = "{ encodeentities( l.name ) }">
				<MvLOCALIZED-TEXT LANGUAGE = "en-US">Your %store_name% password</MvLOCALIZED-TEXT>
			</MvLOCALIZED>

			<MvLOCALIZED NAME = "CustomerEmail.d.header" ID = "MER-CUS-DB-00002">
				<MvLOCALIZED-TEXT LANGUAGE = "en-US">Here is the account information you requested.</MvLOCALIZED-TEXT>
			</MvLOCALIZED>

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

		<MvIF EXPR = "{ l.ok }">
			<MvCLOSE NAME = "CustomerEmail">
			<MvASSIGN NAME = "g._DB_Store_CustomerEmail_Open" VALUE = 0>
		</MvIF>
	</MvIF>
	<MvIF EXPR = "{ l.ok }">
		<MvDO FILE = "{  g.Module_Library_DB }" NAME = "l.ok" VALUE = "{ StoreKey_Insert( 'Customers', 1 ) }">
	</MvIF>
	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "CUS_Store_Pack" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = "{ _DB_Store_Open_Customers() }">
	<MvIF EXPR = "{ l.ok }">
		<MvPACK NAME = "Customers">
		<MvIF EXPR = "{ MvPACK_Error }">
			<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-DTB-00258', MvPACK_Error ) }">
		<MvELSE>
			<MvCLOSE NAME = "Customers">
			<MvASSIGN NAME = "g._DB_Store_Customers_Open" VALUE = 0>
		</MvIF>
	</MvIF>

	<MvIF EXPR = "{ l.ok }">
		<MvASSIGN NAME = "l.ok" VALUE = "{ _DB_Store_Open_CustomerEmail() }">
		<MvIF EXPR = "{ l.ok }">
			<MvPACK NAME = "CustomerEmail">
			<MvIF EXPR = "{ MvPACK_Error }">
				<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-DTB-00259', MvPACK_Error ) }">
			<MvELSE>
				<MvCLOSE NAME = "CustomerEmail">
				<MvASSIGN NAME = "g._DB_Store_CustomerEmail_Open" VALUE = 0>
			</MvIF>
		</MvIF>
	</MvIF>

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

<MvFUNCTION NAME = "CUS_Store_Delete">
	<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 $ 'customer.dbf' ) }">
	<MvASSIGN NAME = "l.deleted" VALUE = "{ fdelete( l.directory $ 'cust_id.mvx' ) }">
	<MvASSIGN NAME = "l.deleted" VALUE = "{ fdelete( l.directory $ 'cust_lgn.mvx' ) }">
	<MvASSIGN NAME = "l.deleted" VALUE = "{ fdelete( l.directory $ 'cust_pgrp.mvx' ) }">
	<MvASSIGN NAME = "l.deleted" VALUE = "{ fdelete( l.directory $ 'custeml.dbf' ) }">
	<MvASSIGN NAME = "l.deleted" VALUE = "{ fdelete( l.directory $ 'custeml.dbt' ) }">

	<MvFUNCTIONRETURN VALUE = 1>
</MvFUNCTION>

<MvFUNCTION NAME = "CUS_Store_Close" STANDARDOUTPUTLEVEL = "">
	<MvIF EXPR = "{ g._DB_Store_Customers_Open }">
		<MvCLOSE NAME = "Customers">
		<MvASSIGN NAME = "g._DB_Store_Customers_Open" VALUE = 0>
	</MvIF>

	<MvIF EXPR = "{ g._DB_Store_CustomerEmail_Open }">
		<MvCLOSE NAME = "CustomerEmail">
		<MvASSIGN NAME = "g._DB_Store_CustomerEmail_Open" VALUE = 0>
	</MvIF>
</MvFUNCTION>

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

	<MvASSIGN NAME = "l.filter" VALUE = "( NOT Customers.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._customer_word[' $ l.pos $ '] CIN Customers.d.login ) OR
			( g._customer_word[' $ l.pos $ '] CIN Customers.d.pw_email ) OR
			( g._customer_word[' $ l.pos $ '] CIN Customers.d.ship_fname ) OR
			( g._customer_word[' $ l.pos $ '] CIN Customers.d.ship_lname ) OR
			( g._customer_word[' $ l.pos $ '] CIN Customers.d.ship_email ) OR
			( g._customer_word[' $ l.pos $ '] CIN Customers.d.ship_comp ) OR
			( g._customer_word[' $ l.pos $ '] CIN Customers.d.ship_phone ) OR
			( g._customer_word[' $ l.pos $ '] CIN Customers.d.ship_fax ) OR
			( g._customer_word[' $ l.pos $ '] CIN Customers.d.ship_addr ) OR
			( g._customer_word[' $ l.pos $ '] CIN Customers.d.ship_state ) OR
			( g._customer_word[' $ l.pos $ '] CIN Customers.d.ship_city ) OR
			( g._customer_word[' $ l.pos $ '] CIN Customers.d.ship_zip ) OR
			( g._customer_word[' $ l.pos $ '] CIN Customers.d.ship_cntry ) OR
			( g._customer_word[' $ l.pos $ '] CIN Customers.d.bill_fname ) OR
			( g._customer_word[' $ l.pos $ '] CIN Customers.d.bill_lname ) OR
			( g._customer_word[' $ l.pos $ '] CIN Customers.d.bill_email ) OR
			( g._customer_word[' $ l.pos $ '] CIN Customers.d.bill_phone ) OR
			( g._customer_word[' $ l.pos $ '] CIN Customers.d.bill_fax ) OR
			( g._customer_word[' $ l.pos $ '] CIN Customers.d.bill_comp ) OR
			( g._customer_word[' $ l.pos $ '] CIN Customers.d.bill_addr ) OR
			( g._customer_word[' $ l.pos $ '] CIN Customers.d.bill_state ) OR
			( g._customer_word[' $ l.pos $ '] CIN Customers.d.bill_zip ) OR
			( g._customer_word[' $ l.pos $ '] CIN Customers.d.bill_cntry ) )' }">
		<MvASSIGN NAME = "l.pos" VALUE = "{ l.pos + 1 }">
	</MvWHILE>

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

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

	<MvIF EXPR = "{ NOT g._DB_Store_Customers_Open }">
		<MvOPEN NAME = "Customers" 
				DATABASE = "{ g._DB_Store_Directory $ 'customer.dbf' }" 
				INDEXES = "{ g._DB_Store_Directory $ 'cust_id.mvx, ' $
					         g._DB_Store_Directory $ 'cust_lgn.mvx' }">
		<MvIF EXPR = "{ MvOPEN_Error }">
			<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-CDB-00277', MvOPEN_Error ) }">
		<MvELSE>
			<MvFILTER NAME = "Customers" FILTER = "{ NOT Customers.d.deleted }">
			<MvASSIGN NAME = "g._DB_Store_Customers_Open" VALUE = 1>
		</MvIF>
	</MvIF>

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

<MvFUNCTION NAME = "Customer_Insert" PARAMETERS = "login, pw_email, password, ship_fname, ship_lname, ship_email, 
												   ship_comp, ship_phone, ship_fax, ship_addr, ship_city, ship_state, 
												   ship_zip, ship_cntry, bill_fname, bill_lname, bill_email, 
												   bill_comp, bill_phone, bill_fax, bill_addr, bill_city, 
												   bill_state, bill_zip, bill_cntry" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.cust_id" VALUE = 0>
	<MvIF EXPR = "{ _DB_Store_Open_Customers() }">
		<MvDO FILE = "{ g.Module_Library_DB }" NAME = "Customers.d.id" VALUE = "{ StoreKey_Generate( 'Customers' ) }">
		<MvASSIGN NAME = "Customers.d.pgrpcount" VALUE = 0>
		<MvASSIGN NAME = "Customers.d.login" VALUE = "{ l.login }">
		<MvASSIGN NAME = "Customers.d.pw_email" VALUE = "{ l.pw_email }">
		<MvASSIGN NAME = "Customers.d.password" VALUE = "{ l.password }">
		<MvASSIGN NAME = "Customers.d.ship_fname" VALUE = "{ l.ship_fname }">
		<MvASSIGN NAME = "Customers.d.ship_lname" VALUE = "{ l.ship_lname }">
		<MvASSIGN NAME = "Customers.d.ship_email" VALUE = "{ l.ship_email }">
		<MvASSIGN NAME = "Customers.d.ship_comp" VALUE = "{ l.ship_comp }">
		<MvASSIGN NAME = "Customers.d.ship_phone" VALUE = "{ l.ship_phone }">
		<MvASSIGN NAME = "Customers.d.ship_fax" VALUE = "{ l.ship_fax }">
		<MvASSIGN NAME = "Customers.d.ship_addr" VALUE = "{ l.ship_addr }">
		<MvASSIGN NAME = "Customers.d.ship_city" VALUE = "{ l.ship_city }">
		<MvASSIGN NAME = "Customers.d.ship_state" VALUE = "{ l.ship_state }">
		<MvASSIGN NAME = "Customers.d.ship_zip" VALUE = "{ l.ship_zip }">
		<MvASSIGN NAME = "Customers.d.ship_cntry" VALUE = "{ l.ship_cntry }">
		<MvASSIGN NAME = "Customers.d.bill_fname" VALUE = "{ l.bill_fname }">
		<MvASSIGN NAME = "Customers.d.bill_lname" VALUE = "{ l.bill_lname }">
		<MvASSIGN NAME = "Customers.d.bill_email" VALUE = "{ l.bill_email }">
		<MvASSIGN NAME = "Customers.d.bill_comp" VALUE = "{ l.bill_comp }">
		<MvASSIGN NAME = "Customers.d.bill_phone" VALUE = "{ l.bill_phone }">
		<MvASSIGN NAME = "Customers.d.bill_fax" VALUE = "{ l.bill_fax }">
		<MvASSIGN NAME = "Customers.d.bill_addr" VALUE = "{ l.bill_addr }">
		<MvASSIGN NAME = "Customers.d.bill_city" VALUE = "{ l.bill_city }">
		<MvASSIGN NAME = "Customers.d.bill_state" VALUE = "{ l.bill_state }">
		<MvASSIGN NAME = "Customers.d.bill_zip" VALUE = "{ l.bill_zip }">
		<MvASSIGN NAME = "Customers.d.bill_cntry" VALUE = "{ l.bill_cntry }">

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

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

<MvFUNCTION NAME = "Customer_Update" PARAMETERS = "id, login, pw_email, password, ship_fname, ship_lname, ship_email,
												   ship_comp, ship_phone, ship_fax, ship_addr, ship_city, ship_state, 
												   ship_zip, ship_cntry, bill_fname, bill_lname, bill_email, 
												   bill_comp, bill_phone, bill_fax, bill_addr, bill_city, 
												   bill_state, bill_zip, bill_cntry" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = "{ _DB_Store_Open_Customers() }">
	<MvIF EXPR = "{ l.ok }">
		<MvPRIMARY NAME = "Customers" INDEX = "{ g._DB_Store_Directory $ 'cust_id.mvx' }">
		<MvFIND NAME = "Customers" VALUE = "{ l.id }" EXACT>
		<MvIF EXPR = "{ Customers.d.EOF }">
			<MvLOCALIZED NAME = "l.error" ID = "MER-CUS-DB-00003">
				<MvLOCALIZED-TOKEN NAME = "id" VALUE = "{ encodeentities( l.id ) }">
				<MvLOCALIZED-TEXT LANGUAGE = "en-US">Customer '%id%' not found</MvLOCALIZED-TEXT>
			</MvLOCALIZED>

			<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-CDB-00278', l.error ) }">
		<MvELSE>
			<MvASSIGN NAME = "Customers.d.login" VALUE = "{ l.login }">
			<MvASSIGN NAME = "Customers.d.pw_email" VALUE = "{ l.pw_email }">

			<MvIF EXPR = "{ len( l.password ) }">
				<MvASSIGN NAME = "Customers.d.password" VALUE = "{ l.password }">
			</MvIF>

			<MvASSIGN NAME = "Customers.d.ship_fname" VALUE = "{ l.ship_fname }">
			<MvASSIGN NAME = "Customers.d.ship_lname" VALUE = "{ l.ship_lname }">
			<MvASSIGN NAME = "Customers.d.ship_email" VALUE = "{ l.ship_email }">
			<MvASSIGN NAME = "Customers.d.ship_comp" VALUE = "{ l.ship_comp }">
			<MvASSIGN NAME = "Customers.d.ship_phone" VALUE = "{ l.ship_phone }">
			<MvASSIGN NAME = "Customers.d.ship_fax" VALUE = "{ l.ship_fax }">
			<MvASSIGN NAME = "Customers.d.ship_addr" VALUE = "{ l.ship_addr }">
			<MvASSIGN NAME = "Customers.d.ship_city" VALUE = "{ l.ship_city }">
			<MvASSIGN NAME = "Customers.d.ship_state" VALUE = "{ l.ship_state }">
			<MvASSIGN NAME = "Customers.d.ship_zip" VALUE = "{ l.ship_zip }">
			<MvASSIGN NAME = "Customers.d.ship_cntry" VALUE = "{ l.ship_cntry }">
			<MvASSIGN NAME = "Customers.d.bill_fname" VALUE = "{ l.bill_fname }">
			<MvASSIGN NAME = "Customers.d.bill_lname" VALUE = "{ l.bill_lname }">
			<MvASSIGN NAME = "Customers.d.bill_email" VALUE = "{ l.bill_email }">
			<MvASSIGN NAME = "Customers.d.bill_comp" VALUE = "{ l.bill_comp }">
			<MvASSIGN NAME = "Customers.d.bill_phone" VALUE = "{ l.bill_phone }">
			<MvASSIGN NAME = "Customers.d.bill_fax" VALUE = "{ l.bill_fax }">
			<MvASSIGN NAME = "Customers.d.bill_addr" VALUE = "{ l.bill_addr }">
			<MvASSIGN NAME = "Customers.d.bill_city" VALUE = "{ l.bill_city }">
			<MvASSIGN NAME = "Customers.d.bill_state" VALUE = "{ l.bill_state }">
			<MvASSIGN NAME = "Customers.d.bill_zip" VALUE = "{ l.bill_zip }">
			<MvASSIGN NAME = "Customers.d.bill_cntry" VALUE = "{ l.bill_cntry }">

			<MvUPDATE NAME = "Customers">
		</MvIF>
	</MvIF>

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

<MvFUNCTION NAME = "Customer_Delete" PARAMETERS = "id" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = "{ _DB_Store_Open_Customers() }">
	<MvIF EXPR = "{ l.ok }">

		<MvPRIMARY NAME = "Customers" INDEX = "{ g._DB_Store_Directory $ 'cust_id.mvx' }">

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

			<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-CDB-00279', l.error ) }">
		<MvELSE>
			<MvDELETE NAME = "Customers">
		</MvIF>
	</MvIF>

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

<MvFUNCTION NAME = "Customer_Find_ID" PARAMETERS = "id" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.found" VALUE = 0>
	<MvIF EXPR = "{ _DB_Store_Open_Customers() }">
		<MvPRIMARY NAME = "Customers" INDEX = "{ g._DB_Store_Directory $ 'cust_id.mvx' }">
		<MvFIND NAME = "Customers" VALUE = "{ l.id }" EXACT>
		<MvIF EXPR = "{ Customers.d.EOF }">
			<MvLOCALIZED NAME = "l.error" ID = "MER-CUS-DB-00005">
				<MvLOCALIZED-TOKEN NAME = "id" VALUE = "{ encodeentities( l.id ) }">
				<MvLOCALIZED-TEXT LANGUAGE = "en-US">Customer '%id%' not found</MvLOCALIZED-TEXT>
			</MvLOCALIZED>

			<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-CDB-00280', l.error ) }">
		<MvELSE>
			<MvASSIGN NAME = "l.found" VALUE = 1>
		</MvIF>
	</MvIF>
		
	<MvFUNCTIONRETURN VALUE = "{ l.found }">
</MvFUNCTION>

<MvFUNCTION NAME = "Customer_FindFirst" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.found" VALUE = 0>
	<MvIF EXPR = "{ _DB_Store_Open_Customers() }">
		<MvPRIMARY NAME = "Customers" INDEX = "{ g._DB_Store_Directory $ 'cust_id.mvx' }">
		<MvGO NAME = "Customers" ROW = "top">

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

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

<MvFUNCTION NAME = "Customer_FindLast" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.found" VALUE = 0>
	<MvIF EXPR = "{ _DB_Store_Open_Customers() }">
		<MvPRIMARY NAME = "Customers" INDEX = "{ g._DB_Store_Directory $ 'cust_id.mvx' }">
		<MvGO NAME = "Customers" ROW = "bottom">

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

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

<MvFUNCTION NAME = "Customer_FindNext" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.found" VALUE = 1>
	<MvPRIMARY NAME = "Customers" INDEX = "{ g._DB_Store_Directory $ 'cust_id.mvx' }">
	<MvSKIP NAME = "Customers" ROWS = 1>
	<MvIF EXPR = "{ Customers.d.EOF }">
		<MvASSIGN NAME = "l.found" VALUE = 0>
	</MvIF>

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

<MvFUNCTION NAME = "Customer_FindNext_CustomerID" PARAMETERS = "login" STANDARDOUTPUTLEVEL = "">
	<MvIF EXPR = "{ _DB_Store_Open_Customers() }">
		<MvASSIGN NAME = "l.found" VALUE = "{ Customer_Find_Login( l.login ) }">
		<MvIF EXPR = "{ l.found }">
			<MvASSIGN NAME = "l.id" VALUE = "{ Customers.d.id }">
			<MvASSIGN NAME = "l.found" VaLUE = "{ Customer_Find_ID( l.id ) }">
			<MvIF EXPR = "{ l.found }">
				<MvSKIP NAME = "Customers" ROWS = 1>
				<MvIF EXPR = "{ NOT Customers.d.EOF }">
					<MvASSIGN NAME = "l.found" VALUE = 1>
				<MvELSE>
					<MvASSIGN NAME = "l.found" VALUE = 0>
				</MvIF>
			<MvELSE>
				<MvASSIGN NAME = "l.found" VALUE = 0>
			</MvIF>
		</MvIF>
	</MvIF>

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

<MvFUNCTION NAME = "Customer_FindPrev_CustomerID" PARAMETERS = "login" STANDARDOUTPUTLEVEL = "">
	<MvIF EXPR = "{ _DB_Store_Open_Customers() }">
		<MvASSIGN NAME = "l.found" VALUE = "{ Customer_Find_Login( l.login ) }">
		<MvIF EXPR = "{ l.found }">
			<MvASSIGN NAME = "l.id" VALUE = "{ Customers.d.id }">
			<MvASSIGN NAME = "l.found" VaLUE = "{ Customer_Find_ID( l.id ) }">
			<MvIF EXPR = "{ l.found }">
				<MvSKIP NAME = "Customers" ROWS = -1>
				<MvIF EXPR = "{ NOT Customers.d.EOF }">
					<MvASSIGN NAME = "l.found" VALUE = 1>
				<MvELSE>
					<MvASSIGN NAME = "l.found" VALUE = 0>
				</MvIF>
			<MvELSE>
				<MvASSIGN NAME = "l.found" VALUE = 0>
			</MvIF>
		</MvIF>
	</MvIF>

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

<MvFUNCTION NAME = "Customer_Find_Login" PARAMETERS = "login" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.found" VALUE = 0>
	<MvIF EXPR = "{ _DB_Store_Open_Customers() }">
		<MvPRIMARY NAME = "Customers" INDEX = "{ g._DB_Store_Directory $ 'cust_lgn.mvx' }">

		<MvFIND NAME = "Customers" VALUE = "{ toupper( l.login ) }" EXACT>
		<MvIF EXPR = "{ NOT Customers.d.EOF }">
			<MvASSIGN NAME = "l.found" VALUE = 1>
		<MvELSE>
			<MvASSIGN NAME = "l.found" VALUE = 0>
		</MvIF>
	</MvIF>

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

<MvFUNCTION NAME = "Customer_FindOffset_Words" PARAMETERS = "words, offset" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.found" VALUE = 0>
	<MvIF EXPR = "{ _DB_Store_Open_Customers() }">
		<MvPRIMARY NAME = "Customers" INDEX = "{ g._DB_Store_Directory $ 'cust_id.mvx' }">
		<MvASSIGN NAME = "l.word" VALUE = 1>
		<MvASSIGN NAME = "g._findoffset_word" INDEX = "{ l.word }" VALUE = "{ gettoken( l.words, ' ', l.word ) }">
		<MvWHILE EXPR = "{ g._findoffset_word[ l.word ] }">
			<MvASSIGN NAME = "l.word" VALUE = "{ l.word + 1 }">
			<MvASSIGN NAME = "g._findoffset_word" INDEX = "{ l.word }" VALUE = "{ gettoken( l.words, ' ', l.word ) }">
		</MvWHILE>

		<MvASSIGN NAME = "l.filter" VALUE = "( _Customer_Filter( l.words ) }">
		<MvFILTER NAME = "Customers" FILTER = "l.filter" FILTER_TYPE = "variable">
		<MvSKIP NAME = "Customers" ROWS = "{ l.offset }">
		<MvIF EXPR = "{ NOT Customers.d.EOF }">
			<MvASSIGN NAME = "l.found" VALUE = 1>
		</MvIF>
	</MvIF>

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

<MvFUNCTION NAME = "Customer_FindNext_Words" PARAMETERS = "words" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.found" VALUE = 1>

	<MvSKIP NAME = "Customers" ROWS = 1>
	<MvIF EXPR = "{ Customers.d.EOF }">
		<MvASSIGN NAME = "l.found" VALUE = 0>
		<MvFILTER NAME = "Customers" FILTER = "{ NOT Customers.d.deleted }">
	</MvIF>

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

<MvFUNCTION NAME = "Customer_FindFirst_Offset" PARAMETERS = "offset" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.found" VALUE = 0>
	<MvIF EXPR = "{ _DB_Store_Open_Customers() }">
		<MvPRIMARY NAME = "Customers" INDEX = "{ g._DB_Store_Directory $ 'cust_id.mvx' }">

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

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

<MvFUNCTION NAME = "Customer_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_Customers() }">
		<MvPRIMARY NAME = "Customers" INDEX = "{ g._DB_Store_Directory $ 'cust_id.mvx' }">
		<MvASSIGN NAME = "l.filter" VALUE = "{ _Customer_Filter( l.search ) }">
		<MvFILTER NAME = "Customers" FILTER = "l.filter" FILTER_TYPE = "variable">

		<MvSKIP NAME = "Customers" ROWS = "{ l.offset }">
		<MvIF EXPR = "{ NOT Customers.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 = "Customer_FindNext_All" PARAMETERS = "offset, search" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.found" VALUE = 0>
	<MvASSIGN NAME = "l.newoffset" VALUE = "{ l.offset + 1 }">

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

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

<MvCOMMENT>
|
| CustomerEmail
|
</MvCOMMENT>

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

	<MvIF EXPR = "{ NOT g._DB_Store_CustomerEmail_Open }">
		<MvOPEN NAME = "CustomerEmail" DATABASE = "{ g._DB_Store_Directory $ 'custeml.dbf' }">
		<MvIF EXPR = "{ MvOPEN_Error }">
			<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-CDB-00281', MvOPEN_Error ) }">
		<MvELSE>
			<MvFILTER NAME = "CustomerEmail" FILTER = "{ NOT CustomerEmail.d.deleted }">
			<MvASSIGN NAME = "g._DB_Store_CustomerEmail_Open" VALUE = 1>
		</MvIF>
	</MvIF>
	
	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>

<MvFUNCTION NAME = "CustomerEmail_Load" STANDARDOUTPUTLEVEL = "">
	<MvFUNCTIONRETURN VALUE = "{ _DB_Store_Open_CustomerEmail() }">
</MvFUNCTION>
		
<MvFUNCTION NAME = "CustomerEmail_Update" PARAMETERS = "from, cc, subject, header" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = "{ _DB_Store_Open_CustomerEmail() }">
	
	<MvIF EXPR = "{ l.ok }">
		<MvASSIGN NAME = "CustomerEmail.d.from" VALUE = "{ l.from }">
		<MvASSIGN NAME = "CustomerEmail.d.cc" VALUE = "{ l.cc }">
		<MvASSIGN NAME = "CustomerEmail.d.subject" VALUE = "{ l.subject }">
		<MvASSIGN NAME = "CustomerEmail.d.header" VALUE = "{ l.header }">

		<MvUPDATE NAME = "CustomerEmail">
	</MvIF>

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

