<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/
|
| $Source: /home/cvs/merchant/Merchant/features/stp/stp_db.mv,v $
|
| Prefix         : MER-STP-DB-
| Next Error Code: 22   
| Next Text ID   : 12   
|
</MvCOMMENT>

<MvFUNCTION NAME = "STP_Store_Delete" PARAMETERS = "" 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 $ 'stasks.dbf' ) }">
	<MvASSIGN NAME = "l.deleted" VALUE = "{ fdelete( l.directory $ 'stsk_id.mvx' ) }">

	<MvFUNCTIONRETURN VALUE = "1">
</MvFUNCTION>

<MvFUNCTION NAME = "STP_DeleteDataFiles" PARAMETERS = "" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = 1>
	<MvASSIGN NAME = "l.directory" VALUE = "{ g.MerchantPath }">

	<MvASSIGN NAME = "l.deleted" VALUE = "{ fdelete( l.directory $ 'tasks.dbf' ) }">
	<MvASSIGN NAME = "l.deleted" VALUE = "{ fdelete( l.directory $ 'task_cod.mvx' ) }">
	<MvASSIGN NAME = "l.deleted" VALUE = "{ fdelete( l.directory $ 'task_id.mvx' ) }">
	<MvASSIGN NAME = "l.deleted" VALUE = "{ fdelete( l.directory $ 'task_lid.mvx' ) }">

	<MvFUNCTIONRETURN VALUE = "1">
</MvFUNCTION>

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

	<MvIF EXPR = "{ l.ok }">
		<MvCREATE NAME = "Tasks"
					DATABASE = "{ g.MerchantPath $ 'tasks.dbf' }"
					FIELDS = "	id 			NUMBER,
								parent_id	NUMBER,
								code		CHAR( 50 ),
								module		CHAR( 50 ),
								params		CHAR( 254 ),
								label		CHAR( 100 ),
								level		CHAR( 1 ),
								completed	BOOL,
								privilege	CHAR( 5 ),
								view		BOOL,
								add			BOOL,
								modify		BOOL,
								delete		BOOL">

		<MvIF EXPR = "{ MvCREATE_Error }">
			<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-STP-DB-00001', MvCREATE_Error ) }">
		<MvELSE>
			<MvASSIGN NAME = "g._DB_Tasks_Open" VALUE = 1>
		</MvIF>

		<MvIF EXPR = "{ l.ok }">
			<MvMAKEINDEX NAME = "Tasks"
						 INDEXFILE = "{ g.MerchantPath $ 'task_id.mvx' }"
						 EXPRESSION = "{ Tasks.d.id }"
						 FLAGS = "unique, ascending">
			<MvIF EXPR = "{ MvMAKEINDEX_Error }">
				<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-STP-DB-00002', MvMAKEINDEX_Error ) }">
			</MvIF>
		</MvIF>

		<MvIF EXPR = "{ l.ok }">
			<MvMAKEINDEX NAME = "Tasks"
						 INDEXFILE = "{ g.MerchantPath $ 'task_lid.mvx' }"
						 EXPRESSION = "{ toupper( Tasks.d.level ) $ ':' $ padl( Tasks.d.id, 10, '0' ) }"
						 FLAGS = "unique, ascending">
			<MvIF EXPR = "{ MvMAKEINDEX_Error }">
				<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-STP-DB-00003', MvMAKEINDEX_Error ) }">
			</MvIF>
		</MvIF>

		<MvIF EXPR = "{ l.ok }">
			<MvMAKEINDEX NAME = "Tasks"
						 INDEXFILE = "{ g.MerchantPath $ 'task_cod.mvx' }"
						 EXPRESSION = "{ Tasks.d.code }"
						 FLAGS = "ascending">
			<MvIF EXPR = "{ MvMAKEINDEX_Error }">
				<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-STP-DB-00004', MvMAKEINDEX_Error ) }">
			</MvIF>
		</MvIF>

		<MvIF EXPR = "{ l.ok }">
			<MvDO FILE = "{ g.Module_Library_DB }" NAME = "l.ok" VALUE = "{ Key_Insert( 'Tasks' ) }">
		</MvIF>

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

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

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

	<MvIF EXPR = "{ l.ok }">
		<MvCREATE NAME = "StoreTasks"
					DATABASE = "{ g._DB_Store_Directory $ 'stasks.dbf' }"
					FIELDS = "	id 			NUMBER,
								completed	BOOL">
		<MvIF EXPR = "{ MvCREATE_Error }">
			<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-STP-DB-00005', MvCREATE_Error ) }">
		<MvELSE>
			<MvASSIGN NAME = "g._DB_Store_Stasks_Open" VALUE = 1>
		</MvIF>

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

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

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

<MvFUNCTION NAME = "STP_Store_Close" STANDARDOUTPUTLEVEL = "">
	<MvIF EXPR = "{ g._DB_Store_Stasks_Open }">
		<MvCLOSE NAME = "StoreTasks">
		<MvASSIGN NAME = "g._DB_Store_Stasks_Open" VALUE = 0>
	</MvIF>

	<MvFUNCTIONRETURN VALUE = "1">
</MvFUNCTION>

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

	<MvIF EXPR = "{ l.ok }">
		<MvASSIGN NAME = "l.ok" VALUE = "{ _DB_Open_Tasks() }">
		<MvIF EXPR = "{ l.ok }">
			<MvPACK NAME = "Tasks">
			<MvIF EXPR = "{ MvPACK_Error }">
				<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-STP-DB-00019', MvPACK_Error ) }">
			<MvELSE>
				<MvCLOSE NAME = "Tasks">
				<MvASSIGN NAME = "g._DB_Tasks_Open" VALUE = 0>
			</MvIF>
		</MvIF>
	</MvIF>

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

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

	<MvIF EXPR = "{ l.ok }">
		<MvASSIGN NAME = "l.ok" VALUE = "{ _DB_Open_Store_Tasks() }">
		<MvIF EXPR = "{ l.ok }">
			<MvPACK NAME = "StoreTasks">
			<MvIF EXPR = "{ MvPACK_Error }">
				<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-STP-DB-00020', MvPACK_Error ) }">
			<MvELSE>
				<MvCLOSE NAME = "StoreTasks">
				<MvASSIGN NAME = "g._DB_Store_Stasks_Open" VALUE = "">
			</MvIF>
		</MvIF>
	</MvIF>

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

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

	<MvIF EXPR = "{ ( len( g._DB_Store_Stasks_Open ) ) AND ( g._DB_Store_Directory NE g._DB_Store_Stasks_Open ) }">
		<MvCLOSE NAME = "StoreTasks">
		<MvASSIGN NAME = "g._DB_Store_Stasks_Open" VALUE = "">
	</MvIF>

	<MvIF EXPR = "{ len( g._DB_Store_Stasks_Open ) EQ 0 }">
		<MvOPEN NAME = "StoreTasks" 
				DATABASE = "{ g._DB_Store_Directory $ 'stasks.dbf' }" 
				INDEXES = "{ g._DB_Store_Directory $ 'stsk_id.mvx' }">
		<MvIF EXPR = "{ MvOPEN_Error }">
			<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-STP-DB-00007', MvOPEN_Error ) }">
		<MvELSE>
			<MvFILTER NAME = "StoreTasks" FILTER = "{ NOT StoreTasks.d.deleted }">
			<MvASSIGN NAME = "g._DB_Store_Stasks_Open" VALUE = "{ g._DB_Store_Directory }">
		</MvIF>
	</MvIF>

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

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

	<MvIF EXPR = "{ NOT g._DB_Tasks_Open }">
		<MvOPEN NAME = "Tasks" 
				DATABASE = "{ g.MerchantPath $ 'tasks.dbf' }" 
				INDEXES = "{ g.MerchantPath $ 'task_id.mvx, ' $
							 g.MerchantPath $ 'task_lid.mvx, ' $ 
							 g.MerchantPath $ 'task_cod.mvx' }">
		<MvIF EXPR = "{ MvOPEN_Error }">
			<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-STP-DB-00008', MvOPEN_Error ) }">
		<MvELSE>
			<MvFILTER NAME = "Tasks" FILTER = "{ NOT Tasks.d.deleted }">
			<MvASSIGN NAME = "g._DB_Tasks_Open" VALUE = 1>
		</MvIF>
	</MvIF>

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

<MvFUNCTION NAME = "Task_Insert_PRV" PARAMETERS = "code, parent_id, module, label, params, completed" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = "{ _DB_Open_Tasks() }">

	<MvIF EXPR = "{ l.ok }">
		<MvDO FILE = "{ g.Module_Library_DB }" NAME = "Tasks.d.id" VALUE = "{ Key_Generate( 'Tasks' ) }">
		<MvASSIGN NAME = "Tasks.d.code" 		VALUE = "{ l.code }">
		<MvASSIGN NAME = "Tasks.d.parent_id" 	VALUE = "{ l.pid }">
		<MvASSIGN NAME = "Tasks.d.module" 		VALUE = "{ l.module }">
		<MvASSIGN NAME = "Tasks.d.label" 		VALUE = "{ l.label }">
		<MvASSIGN NAME = "Tasks.d.params" 		VALUE = "{ l.params }">
		<MvASSIGN NAME = "Tasks.d.level" 		VALUE = "D">
		<MvASSIGN NAME = "Tasks.d.completed" 	VALUE = "{ l.completed }">
		
		<MvADD NAME = "Tasks">
	</MvIF>

	<MvFUNCTIONRETURN VALUE = "{ Tasks.d.id }">
</MvFUNCTION>

<MvFUNCTION NAME = "Task_Update" PARAMETERS = "id, code, parent_id, module, label, level, params, priv, view, add, modify, delete, completed" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = "{ _DB_Open_Tasks() }">
	<MvIF EXPR = "{ l.ok }">
		<MvPRIMARY NAME = "Tasks" INDEX = "{ g.MerchantPath $ 'task_id.mvx' }">
		<MvFIND NAME = "Tasks" VALUE = "{ l.id }" EXACT>
		<MvIF EXPR = "{ Tasks.d.EOF }">
			<MvLOCALIZED NAME = "l.error" ID = "MER-STP-DB-00001">
				<MvLOCALIZED-TOKEN NAME = "id" VALUE = "{ encodeentities( l.id ) }">
				<MvLOCALIZED-TEXT LANGUAGE = "en-US">Task '%id%' not found</MvLOCALIZED-TEXT>
			</MvLOCALIZED>

			<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-STP-DB-00021', l.error ) }">
		<MvELSE>
			<MvASSIGN NAME = "Tasks.d.code" 		VALUE = "{ l.code }">
			<MvASSIGN NAME = "Tasks.d.parent_id" 	VALUE = "{ l.parent_id }">
			<MvASSIGN NAME = "Tasks.d.module" 		VALUE = "{ l.module }">
			<MvASSIGN NAME = "Tasks.d.label" 		VALUE = "{ l.label }">
			<MvASSIGN NAME = "Tasks.d.params" 		VALUE = "{ l.params }">
			<MvASSIGN NAME = "Tasks.d.level" 		VALUE = "{ l.level }">
			<MvASSIGN NAME = "Tasks.d.completed" 	VALUE = "{ l.completed }">
			
			<MvIF EXPR = "{ l.level EQ 'S' }">
				<MvASSIGN NAME = "Tasks.d.privilege"	VALUE = "{ l.priv }">
				<MvASSIGN NAME = "Tasks.d.view"			VALUE = "{ l.view }">
				<MvASSIGN NAME = "Tasks.d.add"			VALUE = "{ l.add }">
				<MvASSIGN NAME = "Tasks.d.modify"		VALUE = "{ l.modify }">
				<MvASSIGN NAME = "Tasks.d.delete"		VALUE = "{ l.delete }">
			</MvIF>
			
			<MvUPDATE NAME = "Tasks">

			<MvIF EXPR = "{ l.level EQ 'S' }">
				<MvASSIGN NAME = "l.ok" VALUE = "{ _DB_Open_Store_Tasks() }">
				<MvIF EXPR = "{ l.ok }">
					<MvPRIMARY NAME = "StoreTasks" INDEX = "{ g._DB_Store_Directory $ 'stsk_id.mvx' }">
					<MvFIND NAME = "StoreTasks" VALUE = "{ l.id }" EXACT>
					<MvIF EXPR = "{ StoreTasks.d.EOF }">
						<MvLOCALIZED NAME = "l.error" ID = "MER-STP-DB-00003">
							<MvLOCALIZED-TOKEN NAME = "task" VALUE = "{ encodeentities( l.id ) }">
							<MvLOCALIZED-TEXT LANGUAGE = "en-US">Task '%task%' not found</MvLOCALIZED-TEXT>
						</MvLOCALIZED>

						<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-STP-DB-00018', l.error ) }">
					<MvELSE>
						<MvASSIGN NAME = "StoreTasks.d.completed" VALUE = "{ l.completed }">
						<MvUPDATE NAME = "StoreTasks">
					</MvIF>
				</MvIF>
			</MvIF>
		</MvIF>
	</MvIF>

	<MvFUNCTIONRETURN VALUE = "{ l.ok }">
</MvFUNCTION>
	
<MvFUNCTION NAME = "Task_Insert" PARAMETERS = "code, pid, module, label, params, level, priv, view, add, modify, delete, completed" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = "{ _DB_Open_Tasks() }">

	<MvIF EXPR = "{ l.ok }">
		<MvDO FILE = "{ g.Module_Library_DB }" NAME = "Tasks.d.id" VALUE = "{ Key_Generate( 'Tasks' ) }">
		<MvASSIGN NAME = "Tasks.d.code" 		VALUE = "{ l.code }">
		<MvASSIGN NAME = "Tasks.d.parent_id" 	VALUE = "{ l.pid }">
		<MvASSIGN NAME = "Tasks.d.module" 		VALUE = "{ l.module }">
		<MvASSIGN NAME = "Tasks.d.label" 		VALUE = "{ l.label }">
		<MvASSIGN NAME = "Tasks.d.params" 		VALUE = "{ l.params }">
		<MvASSIGN NAME = "Tasks.d.level" 		VALUE = "{ l.level }">
		<MvASSIGN NAME = "Tasks.d.privilege"	VALUE = "{ l.priv }">
		<MvASSIGN NAME = "Tasks.d.view"			VALUE = "{ l.view }">
		<MvASSIGN NAME = "Tasks.d.add"			VALUE = "{ l.add }">
		<MvASSIGN NAME = "Tasks.d.modify"		VALUE = "{ l.modify }">
		<MvASSIGN NAME = "Tasks.d.delete"		VALUE = "{ l.delete }">
		<MvASSIGN NAME = "Tasks.d.completed" 	VALUE = "{ l.completed }">
		
		<MvADD NAME = "Tasks">
	</MvIF>

	<MvFUNCTIONRETURN VALUE = "{ Tasks.d.id }">
</MvFUNCTION>

<MvFUNCTION NAME = "Insert_Store_Tasks" PARAMETERS = "id, completed" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = "{ _DB_Open_Store_Tasks() }">

	<MvIF EXPR = "{ l.ok }">
		<MvASSIGN NAME = "StoreTasks.d.id" 			VALUE = "{ l.id }">
		<MvASSIGN NAME = "StoreTasks.d.completed" 	VALUE = "{ l.completed }">

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

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

<MvFUNCTION NAME = "STP_Task_Delete" PARAMETERS = "id" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = "{ _DB_Open_Tasks() }">
	<MvIF EXPR = "{ l.ok }">
		<MvPRIMARY NAME = "Tasks" INDEX = "{ g.MerchantPath $ 'task_id.mvx' }">
		<MvFIND NAME = "Tasks" VALUE = "{ toupper( l.id ) }" EXACT>
		<MvIF EXPR = "{ Tasks.d.EOF }">
			<MvLOCALIZED NAME = "l.error" ID = "MER-STP-DB-00001">
				<MvLOCALIZED-TOKEN NAME = "id" VALUE = "{ encodeentities( l.id ) }">
				<MvLOCALIZED-TEXT LANGUAGE = "en-US">Task '%id%' not found</MvLOCALIZED-TEXT>
			</MvLOCALIZED>

			<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-STP-DB-00009', l.error ) }">
		<MvELSE>
			<MvDO FILE = "{ g.Module_Library_DB }" NAME = "l.found" VALUE = "{ Store_FindFirst() }">
			<MvWHILE EXPR = "{ l.ok AND l.found }">
				<MvDO FILE = "{ g.Module_Admin }" NAME = "l.ok" VALUE = "{ Admin_Open_Store( Stores.d.code ) }">
				<MvIF EXPR = "{ l.ok }">
					<MvASSIGN NAME = "l.open" VALUE = "{ _DB_Open_Store_Tasks() }">
					
					<MvIF EXPR = "{ l.open }">
						<MvPRIMARY NAME = "StoreTasks" INDEX = "{ g._DB_Store_Directory $ 'stsk_id.mvx' }">
						<MvFIND NAME = "StoreTasks" VALUE = "{ l.id }" EXACT>
						<MvIF EXPR = "{ NOT StoreTasks.d.EOF }">
							<MvDELETE NAME = "StoreTasks">
						</MvIF>
					</MvIF>
				</MvIF>

				<MvDO FILE = "{ g.Module_Library_DB }" NAME = "l.found" VALUE = "{ Store_FindNext() }">
			</MvWHILE>

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

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

<MvFUNCTION NAME = "PRV_StoreTask_MarkCompleted" PARAMETERS = "task_id, store_code, completed" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = 1>
	
	<MvDO FILE = "{ g.Module_Admin }" NAME = "l.ok" VALUE = "{ Admin_Open_Store( l.store_code ) }">
	<MvIF EXPR = "{ l.ok }">
		<MvEVAL EXPR = "{ _DB_Open_Store_Tasks() }">

		<MvPRIMARY NAME = "StoreTasks" INDEX = "{ g._DB_Store_Directory $ 'stsk_id.mvx' }">
		<MvFIND NAME = "StoreTasks" VALUE = "{ l.task_id }" EXACT>
		<MvIF EXPR = "{ StoreTasks.d.EOF }">
			<MvLOCALIZED NAME = "l.error" ID = "MER-STP-DB-00011">
				<MvLOCALIZED-TOKEN NAME = "task" VALUE = "{ encodeentities( l.task_id ) }">
				<MvLOCALIZED-TEXT LANGUAGE = "en-US">Task '%task%' not found</MvLOCALIZED-TEXT>
			</MvLOCALIZED>

			<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-STP-DB-00018', l.error ) }">
		<MvELSE>
			<MvASSIGN NAME = "StoreTasks.d.completed" VALUE = "{ l.completed }">
			<MvUPDATE NAME = "StoreTasks">
		</MvIF>
	</MvIF>

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

<MvFUNCTION NAME = "STP_Task_Completed" PARAMETERS = "task_id" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = "{ _DB_Open_Tasks() }">
	<MvIF EXPR = "{ l.task_id EQ 'F' OR l.task_id EQ 'W' }">
		<MvFUNCTIONRETURN VALUE = 1>
	</MvIF>
	<MvPRIMARY NAME = "Tasks" INDEX = "{ g.MerchantPath $ 'task_id.mvx' }">

	<MvIF EXPR = "{ l.ok }">
		<MvFIND NAME = "Tasks" VALUE = "{ l.task_id }" EXACT>
		<MvIF EXPR = "{ Tasks.d.EOF }">
			<MvLOCALIZED NAME = "l.error" ID = "MER-STP-DB-00002">
				<MvLOCALIZED-TOKEN NAME = "task" VALUE = "{ encodeentities( l.task_id ) }">
				<MvLOCALIZED-TEXT LANGUAGE = "en-US">Task '%task%' not found</MvLOCALIZED-TEXT>
			</MvLOCALIZED>

			<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-STP-DB-00017', l.error ) }">
		<MvELSE>
			<MvIF EXPR = "{ Tasks.d.level EQ 'D' }">
				<MvASSIGN NAME = "Tasks.d.completed" VALUE = 1>
				<MvUPDATE NAME = "Tasks">
			<MvELSE>
				<MvASSIGN NAME = "l.ok" VALUE = "{ _DB_Open_Store_Tasks() }">
				<MvIF EXPR = "{ l.ok }">
					<MvPRIMARY NAME = "StoreTasks" INDEX = "{ g._DB_Store_Directory $ 'stsk_id.mvx' }">
					<MvFIND NAME = "StoreTasks" VALUE = "{ l.task_id }" EXACT>
					<MvIF EXPR = "{ StoreTasks.d.EOF }">
						<MvLOCALIZED NAME = "l.error" ID = "MER-STP-DB-00003">
							<MvLOCALIZED-TOKEN NAME = "task" VALUE = "{ encodeentities( l.task_id ) }">
							<MvLOCALIZED-TEXT LANGUAGE = "en-US">Task '%task%' not found</MvLOCALIZED-TEXT>
						</MvLOCALIZED>

						<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-STP-DB-00018', l.error ) }">
					<MvELSE>
						<MvASSIGN NAME = "StoreTasks.d.completed" VALUE = 1>
						<MvUPDATE NAME = "StoreTasks">
					</MvIF>
				</MvIF>
			</MvIF>
		</MvIF>
	</MvIF>

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

<MvFUNCTION NAME = "Find_TaskID" PARAMETERS = "code" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.found" VALUE = 0>
	<MvIF EXPR = "{ _DB_Open_Tasks() }">
		<MvPRIMARY NAME = "Tasks" INDEX = "{ g.MerchantPath $ 'task_cod.mvx' }">
		<MvFIND NAME = "Tasks" VALUE = "{ l.code }" EXACT>
		<MvIF EXPR = "{ NOT Tasks.d.EOF }">
			<MvASSIGN NAME = "l.found" VALUE = "{ Tasks.d.id }">
		</MvIF>
	</MvIF>

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

<MvFUNCTION NAME = "FindFirst_Task" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.found" VALUE = 0>
	<MvIF EXPR = "{ _DB_Open_Tasks() }">
		<MvPRIMARY NAME = "Tasks" INDEX = "{ g.MerchantPath $ 'task_lid.mvx' }">

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

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

<MvFUNCTION NAME = "FindNext_Task" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.found" VALUE = 0>

	<MvSKIP NAME = "Tasks" ROWS = 1>

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

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


<MvFUNCTION NAME = "FindFirst_DomainTask" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.found" VALUE = 0>
	<MvIF EXPR = "{ _DB_Open_Tasks() }">
		<MvPRIMARY NAME = "Tasks" INDEX = "{ g.MerchantPath $ 'task_lid.mvx' }">

		<MvFIND NAME = "Tasks" VALUE = "D">
		<MvIF EXPR = "{ NOT Tasks.d.EOF }">
			<MvASSIGN NAME = "l.found" VALUE = 1>
			<MvIF EXPR = "{ ( NOT Tasks.d.completed ) AND ( NOT g.Current_Task ) }">
				<MvASSIGN NAME = "g.Current_Task" VALUE = "{ Tasks.d.id }">
			</MvIF>
		</MvIF>
	</MvIF>

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

<MvFUNCTION NAME = "FindFirst_DomainTask_NotCompleted" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.found" VALUE = 0>
	<MvIF EXPR = "{ _DB_Open_Tasks() }">
		<MvPRIMARY NAME = "Tasks" INDEX = "{ g.MerchantPath $ 'task_lid.mvx' }">

		<MvFIND NAME = "Tasks" VALUE = "D">
		<MvWHILE EXPR = "{ ( NOT Tasks.d.EOF ) AND ( Tasks.d.level EQ 'D' ) }">
			<MvDO FILE = "{ g.Module_Library_DB }" NAME = "l.ok" VALUE = "{ Module_Find_Code( Tasks.d.module ) }">
			<MvIF EXPR = "{ l.ok }">
				<MvDO FILE = "{ g.Module_Root $ Modules.d.module }" NAME = "l.can_use" VALUE = "{ WizardModule_Privileges() }">
				<MvIF EXPR = "{ l.can_use }">
					<MvIF EXPR = "{ NOT Tasks.d.completed }">
						<MvASSIGN NAME = "l.is_completed" VALUE = "{ Is_DomainTaskParent_Completed() }">
						<MvIF EXPR = "{ l.is_completed }">
							<MvASSIGN NAME = "l.found" VALUE = "{ Tasks.d.id }">
							<MvWHILESTOP>
						</MvIF>
					</MvIF>
				</MvIF>
			</MvIF>

			<MvSKIP NAME = "Tasks" ROWS = 1>
		</MvWHILE>
	</MvIF>

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

<MvFUNCTION NAME = "FindNext_DomainTask_NotCompleted" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.found" VALUE = 0>

	<MvWHILE EXPR = "{ ( NOT Tasks.d.EOF ) AND ( Tasks.d.level EQ 'D' ) }">
		<MvDO FILE = "{ g.Module_Library_DB }" NAME = "l.ok" VALUE = "{ Module_Find_Code( Tasks.d.module ) }">
		<MvIF EXPR = "{ l.ok }">
			<MvDO FILE = "{ g.Module_Root $ Modules.d.module }" NAME = "l.can_use" VALUE = "{ WizardModule_Privileges() }">
			<MvIF EXPR = "{ l.can_use }">
				<MvIF EXPR = "{ NOT Tasks.d.completed }">
					<MvASSIGN NAME = "l.is_completed" VALUE = "{ Is_DomainTaskParent_Completed() }">
					<MvIF EXPR = "{ l.is_completed }">
						<MvASSIGN NAME = "l.found" VALUE = "{ Tasks.d.id }">
						<MvWHILESTOP>
					</MvIF>
				</MvIF>
			</MvIF>
		</MvIF>

		<MvSKIP NAME = "Tasks" ROWS = 1>
	</MvWHILE>

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

<MvFUNCTION NAME = "FindNext_DomainTask" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.found" VALUE = 0>

	<MvWHILE EXPR = "{ NOT Tasks.d.EOF }">
		<MvSKIP NAME = "Tasks" ROWS = 1>

		<MvIF EXPR = "{ Tasks.d.level EQ 'D' AND NOT Tasks.d.eof }">
			<MvASSIGN NAME = "l.found" VALUE = "{ Tasks.d.id }">

			<MvIF EXPR = "{ ( NOT Tasks.d.completed ) AND ( NOT g.Current_Task ) }">
				<MvASSIGN NAME = "g.Current_Task" VALUE = "{ Tasks.d.id }">
			</MvIF>

			<MvWHILESTOP>
		</MvIF>
	</MvWHILE>

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

<MvFUNCTION NAME = "FindFirst_StoreTask" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.found" VALUE = 0>
	<MvIF EXPR = "{ _DB_Open_Tasks() }">
		<MvPRIMARY NAME = "Tasks" INDEX = "{ g.MerchantPath $ 'task_id.mvx' }">

		<MvGO NAME = "Tasks" ROW = "top">
		<MvASSIGN NAME = "l.rows" VALUE = 0>
		<MvWHILE EXPR = "{ NOT Tasks.d.EOF }">
			<MvIF EXPR = "{ Tasks.d.level EQ 'S' }">
				<MvIF EXPR = "{ _DB_Open_Store_Tasks() }">
					<MvPRIMARY NAME = "StoreTasks" INDEX = "{ g._DB_Store_Directory $ 'stsk_id.mvx' }">
					<MvFIND NAME = "StoreTasks" VALUE = "{ Tasks.d.id }" EXACT>
					<MvIF EXPR = "{ StoreTasks.d.EOF }">
						<MvLOCALIZED NAME = "l.error" ID = "MER-STP-DB-00004">
							<MvLOCALIZED-TOKEN NAME = "id" VALUE = "{ encodeentities( Tasks.d.id ) }">
							<MvLOCALIZED-TEXT LANGUAGE = "en-US">Task '%id%' not found</MvLOCALIZED-TEXT>
						</MvLOCALIZED>

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

					<MvASSIGN NAME = "l.found" VALUE = "{ Tasks.d.id }">
					<MvWHILESTOP>
				</MvIF>
			</MvIF>

			<MvSKIP NAME = "Tasks" ROWS = 1>
		</MvWHILE>
	</MvIF>

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

<MvFUNCTION NAME = "FindNext_StoreTask" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.found" VALUE = 0>

	<MvSKIP NAME = "Tasks" ROWS = 1>

	<MvWHILE EXPR = "{ NOT Tasks.d.EOF }">
		<MvIF EXPR = "{ Tasks.d.level EQ 'S' }">
			<MvIF EXPR = "{ _DB_Open_Store_Tasks() }">
				<MvPRIMARY NAME = "StoreTasks" INDEX = "{ g._DB_Store_Directory $ 'stsk_id.mvx' }">
				<MvFIND NAME = "StoreTasks" VALUE = "{ Tasks.d.id }" EXACT>
				<MvIF EXPR = "{ StoreTasks.d.EOF }">
					<MvLOCALIZED NAME = "l.error" ID = "MER-STP-DB-00005">
						<MvLOCALIZED-TOKEN NAME = "id" VALUE = "{ encodeentities( Tasks.d.id ) }">
						<MvLOCALIZED-TEXT LANGUAGE = "en-US">Task '%id%' not found</MvLOCALIZED-TEXT>
					</MvLOCALIZED>
					<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-STP-DB-00011', l.error ) }">
				</MvIF>
				<MvASSIGN NAME = "l.found" VALUE = "{ Tasks.d.id }">
				<MvWHILESTOP>
			</MvIF>
		</MvIF>

		<MvSKIP NAME = "Tasks" ROWS = 1>
	</MvWHILE>

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

<MvFUNCTION NAME = "FindFirst_StoreTask_Unavailable" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.found" VALUE = 0>
	<MvIF EXPR = "{ _DB_Open_Tasks() }">
		<MvPRIMARY NAME = "Tasks" INDEX = "{ g.MerchantPath $ 'task_lid.mvx' }">

		<MvGO NAME = "Tasks" ROW = "top">

		<MvDO FILE = "{ g.Module_Admin }" NAME = "l.can_use" VALUE = "{ CanI( Tasks.d.privilege, Tasks.d.view, Tasks.d.add, Tasks.d.modify, Tasks.d.delete ) }">

		<MvFIND NAME = "Tasks" VALUE = "S">
		<MvIF EXPR = "{ ( NOT Tasks.d.EOF ) AND ( l.can_use ) }">
			<MvASSIGN NAME = "l.found" VALUE = "{ Tasks.d.id }">
		</MvIF>
	</MvIF>

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

<MvFUNCTION NAME = "FindNext_StoreTask_Unavailable" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.found" VALUE = 0>

	<MvSKIP NAME = "Tasks" ROWS = 1>

	<MvDO FILE = "{ g.Module_Admin }" NAME = "l.can_use" VALUE = "{ CanI( Tasks.d.privilege, Tasks.d.view, Tasks.d.add, Tasks.d.modify, Tasks.d.delete ) }">

	<MvIF EXPR = "{ ( NOT Tasks.d.EOF ) AND ( Tasks.d.level EQ 'S' ) AND ( l.can_use ) }">
		<MvASSIGN NAME = "l.found" VALUE = "{ Tasks.d.id }">
	</MvIF>

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

<MvFUNCTION NAME = "FindFirst_StoreTask_NotCompleted" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.found" VALUE = 0>
	<MvIF EXPR = "{ _DB_Open_Tasks() }">
		<MvPRIMARY NAME = "Tasks" INDEX = "{ g.MerchantPath $ 'task_lid.mvx' }">
		<MvFIND NAME = "Tasks" VALUE = "S">
		<MvWHILE EXPR = "{ ( NOT Tasks.d.EOF ) AND ( Tasks.d.level EQ 'S' ) }">
			<MvDO FILE = "{ g.Module_Admin }" NAME = "l.can_use" VALUE = "{ CanI( Tasks.d.privilege, Tasks.d.view, Tasks.d.add, Tasks.d.modify, Tasks.d.delete ) }">
			<MvIF EXPR = "{ ( _DB_Open_Store_Tasks() ) AND ( l.can_use ) }">
				<MvASSIGN NAME = "l.is_completed" VALUE = "{ Is_StoreTaskParent_Completed() }">
				<MvIF EXPR = "{ l.is_completed }">
					<MvPRIMARY NAME = "StoreTasks" INDEX = "{ g._DB_Store_Directory $ 'stsk_id.mvx' }">
					<MvFIND NAME = "StoreTasks" VALUE = "{ Tasks.d.id }" EXACT>
					<MvIF EXPR = "{ StoreTasks.d.EOF }">
						<MvLOCALIZED NAME = "l.error" ID = "MER-STP-DB-00006">
							<MvLOCALIZED-TOKEN NAME = "id" VALUE = "{ encodeentities( Tasks.d.id ) }">
							<MvLOCALIZED-TEXT LANGUAGE = "en-US">Task '%id%' not found</MvLOCALIZED-TEXT>
						</MvLOCALIZED>

						<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-STP-DB-00012', l.error ) }">
					<MvELSE>
						<MvIF EXPR = "{ NOT StoreTasks.d.completed }">
							<MvASSIGN NAME = "l.found" VALUE = "{ Tasks.d.id }">
							<MvWHILESTOP>
						</MvIF>
					</MvIF>
				</MvIF>
			</MvIF>

			<MvSKIP NAME = "Tasks" ROWS = 1>
		</MvWHILE>
	</MvIF>

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

<MvFUNCTION NAME = "FindNext_StoreTask_NotCompleted" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.found" VALUE = 0>

	<MvWHILE EXPR = "{ ( NOT Tasks.d.EOF ) AND ( Tasks.d.level EQ 'S' ) }">
		<MvDO FILE = "{ g.Module_Admin }" NAME = "l.can_use" VALUE = "{ CanI( Tasks.d.privilege, Tasks.d.view, Tasks.d.add, Tasks.d.modify, Tasks.d.delete ) }">
		<MvIF EXPR = "{ ( _DB_Open_Store_Tasks() ) AND ( l.can_use ) }">
			<MvASSIGN NAME = "l.is_completed" VALUE = "{ Is_StoreTaskParent_Completed() }">
			<MvIF EXPR = "{ l.is_completed }">
				<MvPRIMARY NAME = "StoreTasks" INDEX = "{ g._DB_Store_Directory $ 'stsk_id.mvx' }">
				<MvFIND NAME = "StoreTasks" VALUE = "{ Tasks.d.id }" EXACT>
				<MvIF EXPR = "{ StoreTasks.d.EOF }">
					<MvLOCALIZED NAME = "l.error" ID = "MER-STP-DB-00007">
						<MvLOCALIZED-TOKEN NAME = "id" VALUE = "{ encodeentities( Tasks.d.id ) }">
						<MvLOCALIZED-TEXT LANGUAGE = "en-US">Task '%id%' not found</MvLOCALIZED-TEXT>
					</MvLOCALIZED>

					<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-STP-DB-00013', l.error ) }">
				<MvELSE>
					<MvIF EXPR = "{ ( NOT StoreTasks.d.completed ) AND ( l.can_use ) }">
						<MvASSIGN NAME = "l.found" VALUE = "{ Tasks.d.id }">
						<MvWHILESTOP>
					</MvIF>
				</MvIF>
			</MvIF>
		</MvIF>

		<MvSKIP NAME = "Tasks" ROWS = 1>
	</MvWHILE>

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

<MvFUNCTION NAME = "Is_StoreTaskParent_Completed" STANDARDOUTPUTLEVEL = "">
	<MvIF EXPR = "{ Tasks.d.parent_id EQ 9999999999 }">
		<MvFUNCTIONRETURN VALUE = 0>
	</MvIF>

	<MvASSIGN NAME = "l.Tasks_ReturnRecno" VALUE = "{ Tasks.d.recno }">
	<MvASSIGN NAME = "l.StoreTasks_ReturnRecno" VALUE = "{ StoreTasks.d.recno }">
	<MvASSIGN NAME = "l.p_id" VALUE = "{ Tasks.d.parent_id }">
	<MvASSIGN NAME = "l.Completed" VALUE = 0>

	<MvPRIMARY NAME = "Tasks" INDEX = "{ g.MerchantPath $ 'task_id.mvx' }">
	<MvFIND NAME = "Tasks" VALUE = "{ l.p_id }" EXACT>
	<MvIF EXPR = "{ Tasks.d.EOF }">
		<MvLOCALIZED NAME = "l.error" ID = "MER-STP-DB-00008">
			<MvLOCALIZED-TOKEN NAME = "l.id" VALUE = "{ encodeentities( l.id ) }">
			<MvLOCALIZED-TEXT LANGUAGE = "en-US">Parent Task '%id%' not found</MvLOCALIZED-TEXT>
		</MvLOCALIZED>

		<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-STP-DB-00014', l.error ) }">
	<MvELSE>
		<MvIF EXPR = "{ Tasks.d.level EQ 'D' }">
			<MvASSIGN NAME = "l.Completed" VALUE = "{ Tasks.d.completed }">
		<MvELSE>
			<MvPRIMARY NAME = "StoreTasks" INDEX = "{ g._DB_Store_Directory $ 'stsk_id.mvx' }">			
			<MvFIND NAME = "StoreTasks" VALUE = "{ Tasks.d.id }" EXACT>
			<MvIF EXPR = "{ StoreTasks.d.EOF }">
				<MvLOCALIZED NAME = "l.error" ID = "MER-STP-DB-00009">
					<MvLOCALIZED-TOKEN NAME = "id" VALUE = "{ encodeentities( StoreTasks.d.id ) }">
					<MvLOCALIZED-TEXT LANGUAGE = "en-US">Store Task '%id%' not found</MvLOCALIZED-TEXT>
				</MvLOCALIZED>
				<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-STP-DB-00015', l.error ) }">
			<MvELSE>
				<MvASSIGN NAME = "l.Completed" VALUE = "{ StoreTasks.d.completed }">
			</MvIF>
		</MvIF>
	</MvIF>

	<MvPRIMARY NAME = "Tasks" INDEX = "{ g.MerchantPath $ 'task_lid.mvx' }">
	<MvGO NAME = "Tasks" ROW = "{ l.Tasks_ReturnRecno }">

	<MvGO NAME = "StoreTasks" ROW = "{ l.StoreTasks_ReturnRecno }">
	
	<MvFUNCTIONRETURN VALUE = "{ l.Completed }">
</MvFUNCTION>

<MvFUNCTION NAME = "Is_DomainTaskParent_Completed" STANDARDOUTPUTLEVEL = "">
	<MvIF EXPR = "{ Tasks.d.parent_id EQ 0 }">
		<MvFUNCTIONRETURN VALUE = 1>
	</MvIF>
	<MvIF EXPR = "{ Tasks.d.parent_id EQ '9999999999' }">
		<MvFUNCTIONRETURN VALUE = 0>
	</MvIF>

	<MvASSIGN NAME = "l.Tasks_ReturnRecno" VALUE = "{ Tasks.d.recno }">
	<MvASSIGN NAME = "l.p_id" VALUE = "{ Tasks.d.parent_id }">
	<MvASSIGN NAME = "l.Completed" VALUE = 0>
	
	<MvPRIMARY NAME = "Tasks" INDEX = "{ g.MerchantPath $ 'task_id.mvx' }">
	<MvFIND NAME = "Tasks" VALUE = "{ l.p_id }" EXACT>
	<MvIF EXPR = "{ Tasks.d.EOF }">
		<MvLOCALIZED NAME = "l.error" ID = "MER-STP-DB-00010">
			<MvLOCALIZED-TOKEN NAME = "l.id" VALUE = "{ encodeentities( l.id ) }">
			<MvLOCALIZED-TEXT LANGUAGE = "en-US">Parent Task '%id%' not found</MvLOCALIZED-TEXT>
		</MvLOCALIZED>

		<MvDO FILE = "{ g.Module_Library_Utilities }" NAME = "l.ok" VALUE = "{ Error( 'MER-STP-DB-00016', l.error ) }">
	<MvELSE>
		<MvIF EXPR = "{ Tasks.d.level EQ 'D' }">
			<MvASSIGN NAME = "l.Completed" VALUE = "{ Tasks.d.completed }">
		<MvELSE>
			<MvASSIGN NAME = "l.Completed" VALUE = "">
		</MvIF>
	</MvIF>

	<MvPRIMARY NAME = "Tasks" INDEX = "{ g.MerchantPath $ 'task_lid.mvx' }">
	<MvGO NAME = "Tasks" ROW = "{ l.Tasks_ReturnRecno }">

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

<MvFUNCTION NAME = "CreateStoreTasks" PARAMETERS = "store_code" STANDARDOUTPUTLEVEL = "">
	<MvASSIGN NAME = "l.ok" VALUE = "{ STP_CreateStore() }">
	<MvASSIGN NAME = "g.New_Store" VALUE = "{ l.store_code }">

	<MvIF EXPR = "{ l.ok }">
		<MvASSIGN NAME = "l.found" VALUE = "{ FindFirst_StoreTask() }">
		<MvWHILE EXPR = "{ l.found }">
			<MvASSIGN NAME = "l.ok" VALUE = "{ Insert_Store_Tasks( l.found, 0 ) }">

			<MvASSIGN NAME = "l.found" VALUE = "{ FindNext_StoreTask() }">
		</MvWHILE>
	</MvIF>

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