<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{$language.lblProductCategories}</title>
{include file='CommonJavaScript.tpl'}
<link rel="stylesheet" type="text/css" href="{$view_styles}/common.css" media="screen" />
<link rel="stylesheet" type="text/css" href="{$view_styles}/grid_listing.css" media="screen" />
<link rel="stylesheet" type="text/css" href="{$view_styles}/popup.css" media="screen" />
<link rel="stylesheet" type="text/css" href="{$view_styles}/locationadd.css" media="screen" />
{form->rootpath_script}
{form->basepath_script}
</head>
<body>
<div class="popup-block">
	<div class="clear"></div>
	<!-- Search container starts --> 
        {form->start name="frmSearchProducts" action="" method="post"}          
			<div class="search_container clearfix">
				<div class="inner">
					<ul class="clearfix">
						<li class="column">
							<p class="label-field01">{$language.lblBrandbrandKey}</p> 
							<span class="form-field01">
								{form->textbox name="brandKey" class="text-box" style="width:95%;"} 
							</span>
						</li>
						<li class="column">				 
							<p class="label-field01">{$language.lblBrandbrandName}</p>
							<span class="form-field01"> 
								{form->textbox class="select-box" name="brandName" }
							</span>
						</li> 
						
						<li class="column">{assign var="additionalLink" value=$additionalLink|default:''}
							<p class="label-field01">&nbsp;</p>
							<span class="btn_fltg">{form->submit name="submitBrandSearch" id="submit" class="grayBtn2"  value=$language.lblSearch}              
							{html->anchor href="promotions/ajaxLoadBrands/{$additionalLink}" class="grayBtn2" content="{$language.lblListAll}"}</span>
						</li>           
					</ul>
				</div>
			</div>
		{form->close}
    <!-- Search container ends --> 
	{if $listBrands|@count>0} 
			<div class="form_listing02 clearfix">
				<div class="grid_table00" style="height: 350px;overflow: auto;"> 
					<table width="100%" border="0" cellspacing="0" cellpadding="0"   >
						<thead>
							<tr>
								<th align="left" valign="middle"  width="30%" colspan="2">
									<span class="chkd-item">
										{form->checkbox class="listAllCheckBoxItems v-aline fixing_left"}
									</span>
									{$language.lblBrands}
								</th>
							</tr>
						</thead>
						<tbody>
							{foreach from=$listBrands item="brand" key="key"}
								<tr>
									<td align="left" valign="middle" colspan="2">
										<span class="chkd-item">
											{form->checkbox class="selectCheckBoxItems v-aline fixing_left" name="check_{$brand['brandID']}" value={$brand['brandID']}}											
											<span class="hiddenTitle hide">	 
												{$brand['brandName']}
											</span>
										</span>
										<label for="check_{$brand['brandID']}">
											<strong>{$brand['brandName']}</strong>
										</label>	
									</td>
								</tr>									
							{/foreach}
						</tbody>
					</table/>	
				</div>
				<!--Start: Pagination-->
			<div class="fixing_right pagination_outer">
				{paginate->layout  key="page" label_record="{$language.lblRecorsFound}" label_pages="{$language.lblPages}"} 					
				<div class="clear"></div>
			</div>         
			<!--end: Pagination--> 
				<div class="clear"></div>
			</div>
			<div class="submit-block clearfix textto_center">
				<span>&nbsp; </span> 
				{form->button name="addCategoryButton" class="blueBtn-1" value=$language.lblPromotionSchemaLinkBrands}
				{$language.lblOr} 
				{html->anchor onclick="parent.$.colorbox.close();" id="cancel" class="grayBtn3" caption="{$language.lblCancel}"}
			</div>
	{else}
        <div class="message_info"> {$language.msgNoRecords}</div>	
	{/if}	
</div>
<script>
var lblSelectItem ="{$language.lblSelectItem}";	
$(document).ready(function (){		
$(document).on('click', ".listAllCheckBoxItems", function () {
	if ($(this).prop("checked") == true) {
		$(".selectCheckBoxItems").prop("checked", "checked");
	} else {
		$(".selectCheckBoxItems").removeAttr("checked");
	}
});	
$(document).on('click', "#addCategoryButton", function () {
	if($(".selectCheckBoxItems:checked").size()==0)
	{
		jAlert(lblSelectItem);
		return false;
	} 
	var selectedDataObj = [];
	$('.selectCheckBoxItems:checked').each(function () {        
		selectedDataObj.push({
            id: $(this).val(),
            title: $(this).next(".hiddenTitle").html()
        });
	}); 
	parent.$.colorbox.close();
	parent.addItemFromPicker(selectedDataObj); 
});	
});	
setCheckboxSelected();
function setCheckboxSelected()
{
	var currentSelected = parent.currentPopupPicker.nextAll().find(".popupPickerDataValues:first").val();
	if(currentSelected)
	{
		var selectedIds = currentSelected.split(",");
		$('.selectCheckBoxItems').each(function () { 
			if($.inArray($(this).val(),selectedIds)>-1)
			$(this).prop("checked", "checked");
		});
	}
}
</script>	
</body>
</html>