<inp2:adm_SetPopupSize width="870" height="600"/>

<inp2:m_include t="incs/header"/>

<inp2:m_if check="coupi_IsEntireOrder">
	<inp2:m_SetParam grid="Default"/>
<inp2:m_else/>
	<inp2:m_SetParam grid="CouponItems"/>
</inp2:m_if>

<inp2:m_RenderElement name="combined_header" prefix="coup" section="in-commerce:coupons" title_preset="coupons_items" grid="$grid" pagination="1" pagination_prefix="coupi" tab_preset="Default"/>

<!-- ToolBar -->
<table class="toolbar" height="30" cellspacing="0" cellpadding="0" width="100%" border="0">
<tbody>
	<tr>
  	<td>
  		<script type="text/javascript">
				a_toolbar = new ToolBar();
				a_toolbar.AddButton( new ToolBarButton('select', '<inp2:m_phrase label="la_ToolTip_Save" escape="1"/>', function() {
							submit_event('coup','<inp2:coup_SaveEvent/>');
						}
					) );
				a_toolbar.AddButton( new ToolBarButton('cancel', '<inp2:m_phrase label="la_ToolTip_Cancel" escape="1"/>', function() {
							submit_event('coup','OnCancelEdit');
						}
				 ) );

				a_toolbar.AddButton( new ToolBarSeparator('sep1') );

				a_toolbar.AddButton( new ToolBarButton('prev', '<inp2:m_phrase label="la_ToolTip_Prev" escape="1"/>', function() {
							go_to_id('coup', '<inp2:coup_PrevId/>');
						}
				 ) );
				a_toolbar.AddButton( new ToolBarButton('next', '<inp2:m_phrase label="la_ToolTip_Next" escape="1"/>', function() {
							go_to_id('coup', '<inp2:coup_NextId/>');
						}
				 ) );

				a_toolbar.AddButton( new ToolBarSeparator('sep2') );

				a_toolbar.AddButton( new ToolBarButton('new_item', '<inp2:m_phrase label="la_ToolTip_New_Products" escape="1"/>::<inp2:m_phrase label="la_ToolTip_Add" escape="1"/>',
						function() {
							openSelector('coupi', '<inp2:adm_SelectorLink prefix="coupi" selection_mode="multi" tabs_dependant="no" tab_prefixes="p" no_amp="1" js_escape="1"/>', '');
						} ) );


				a_toolbar.AddButton( new ToolBarButton('delete', '<inp2:m_phrase label="la_ToolTip_Delete" escape="1"/>',
						function() {
							std_delete_items('coupi')
						} ) );

				a_toolbar.AddButton( new ToolBarButton('in-commerce:entire_order', '<inp2:m_phrase label="la_ToolTip_EntireOrder" escape="1"/>',
						function() {
							if (inpConfirm('<inp2:m_phrase label="la_EntireOrderConfirmation"/>'))
							{
								submit_event('coupi', 'OnEntireOrder');
							}
						} ) );
				a_toolbar.AddButton( new ToolBarSeparator('sep3') );

				a_toolbar.AddButton( new ToolBarButton('view', '<inp2:m_phrase label="la_ToolTip_View" escape="1"/>', function() {
							show_viewmenu(a_toolbar,'view');
						}
				) );

				a_toolbar.Render();

				<inp2:m_if check="coup_IsSingle" >
					a_toolbar.HideButton('prev');
					a_toolbar.HideButton('next');
					a_toolbar.HideButton('sep1');
					//a_toolbar.HideButton('sep2');
				<inp2:m_else/>
					<inp2:m_if check="coup_IsLast" >
						a_toolbar.DisableButton('next');
					</inp2:m_if>
					<inp2:m_if check="coup_IsFirst" >
						a_toolbar.DisableButton('prev');
					</inp2:m_if>
				</inp2:m_if>

				function edit()
				{
					// required for correct row selection
				}

			</script>
		</td>

		<inp2:m_RenderElement name="search_main_toolbar" prefix="coupi" grid="$grid"/>
	</tr>
</tbody>
</table>

<inp2:m_DefineElement name="grid_item_td">
	<inp2:m_if check="FieldEquals" field="ItemType" value="1">
		<inp2:Field field="ProductId" no_special="no_special"/>
	<inp2:m_else/>
		<inp2:Field field="CategoryId" no_special="no_special"/>
	</inp2:m_if>
</inp2:m_DefineElement>

<inp2:m_RenderElement name="grid" PrefixSpecial="coupi" IdField="CouponItemId" grid="$grid"/>

<script type="text/javascript">
	<inp2:m_if check="coupi_IsEntireOrder" >
			a_toolbar.DisableButton('new_item');
	</inp2:m_if>

	Grids['coupi'].SetDependantToolbarButtons( new Array('delete') );
</script>

<input type="hidden" name="main_prefix" id="main_prefix" value="coupi">

<inp2:m_include t="incs/footer"/>