<!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.lblAdmin}: {$language.lblManageBuybox}</title>
{include file='CommonStyles.tpl'}
{include file='CommonJavaScript.tpl'}
{include file='CommonCustomStyles.tpl'}
<link rel="stylesheet" type="text/css" href="{$view_styles}/grid_listing.css" media="screen" />
<link href="{$view_styles}/jquery-ui-1.8.19.custom.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="{$view_styles}/ui.daterangepicker.css" />
</head>
<body>
<div class="outer_container">
  {include file='CommonTop.tpl'}
  <!--End:Header Container--> 
  <!--***********************************************************************START CONTAINER SECTION******************************************************-->
  <div class="content_container">
    <div class="content_wrapper">
    <h2 >{$language.lblManageBuybox}</h2>
    
     <div id="common_message"></div>
    <div class="clear"></div>
    <!--End: Right Block-->
    <div class="inner_content_wrapper">
          <div class="search_container">
            <div class="inner wide-box"> {form->start name="formBuyBox" action="" method="post" enctype="multipart/form-data"}
              <ul class="clearfix">
                <li class="column">
                  <p class="label-field01">{$language.lblProductName}</p>                 
                   <span class="form-field01">
                       {form->textbox name="productName" class="text-box" tabindex="1"} 
                    </span>
                </li>
                
                 <li class="column ">    <p class="label-field01">&nbsp;</p>                    
                   <span class="form-field01">
                  {form->submit name="submitSearch" class="button01" form="formBuyBox" tabindex="7" value={$language.lblSearch}}
                   {html->anchor href="/buybox/index/" caption="{$language.lblListAll}" class="action-link" tabindex="8"}
                   </span>
                </li> 
                </ul>
              {*form->close*}
              <div class="clear"></div>
            </div>
          </div>
          <!--END:sEARCH cONTAINER-->
          {form->close}
          
          {if $resProducts}
          <div class="grid_table00"> 
            <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <thead>
              <tr>
                    {if $sortVal ==''}
                        {assign var="sortproduct" value="asc"} 
                         
                    {/if}  
                   
                    {assign var="sortVariable" value="sort"|cat:$sortOrder}
                    {assign var="sort"|cat:$sortVal|cat:"img" value=$sortVariable}
                                       
                   
                    {if $sortOrder eq 'desc'}
                       {assign var='sortOrder' value='asc'}
                    {else if $sortOrder eq 'asc'}
                        {assign var='sortOrder' value='desc'}
                    {else}
                        {assign var='sortOrder' value=''}
                    {/if}
                <th align="left" valign="middle" {if $sortVal=="product"}class={$sortproductimg}{else} class="sort" {/if}>{html->anchor href="{$link}sortby/product/orderby/{if $sortOrder==''}desc{else}{$sortOrder}{/if}/" title=$language.lblProduct content=$language.lblProduct}</th>
                <th align="left" valign="middle" {if $sortVal=="merchant"}class={$sortmerchantimg}{else} class="sort" {/if}>{html->anchor href="{$link}sortby/merchant/orderby/{if $sortOrder==''}desc{else}{$sortOrder}{/if}/" title=$language.lblMerchant content=$language.lblMerchant}</th>
                <th align="left" valign="middle" {if $sortVal=="price"}class={$sortpriceimg}{else}class="sort" {/if}>{html->anchor href="{$link}sortby/price/orderby/{if $sortOrder==''}desc{else}{$sortOrder}{/if}/" title=$language.lblProductPrice content=$language.lblProductPrice}</th>
                <th align="left" valign="middle" class="unsortable" >{$language.lblMerchantRatings}</th>
                <th align="left" valign="middle" class="unsortable" >{$language.lblUserReviews}</th>
                <th align="left" valign="middle" {if $sortVal=="commision"}class={$sortcommisionimg}{else}class="sort" {/if}>{html->anchor href="{$link}sortby/commision/orderby/{if $sortOrder==''}desc{else}{$sortOrder}{/if}/" title=$language.lblAdminCommission|cat:'%' content=$language.lblAdminCommission|cat:'%'}</th>
                {*<th align="left" valign="middle" class="unsortable" >{$language.lblProductSkuProductID}</th>*}
                <th align="left" valign="middle" class="unsortable" >{$language.lblProdStatus}</th>
              </tr>
              </thead>
              {foreach from=$resProducts item="product" key="key1"}
              {assign var="buyboxDetailsID" value=$product.buyboxDetailsID}
              {assign var="buyboxID" value=$product.buyboxID}
              {if $product['busRating'].ratingTotal>0 && $product['busRating'].ratingCount>0}
                {assign var="avgRating" value=$product['busRating'].ratingTotal/$product['busRating'].ratingCount}
              {else}
                {assign var="avgRating" value=0}
              {/if}
              
              {assign var="ratingTotal" value=$product['userRating'].ratingTotal|default:''}
              {assign var="productReviewsCount" value=$product['userRating'].productReviewsCount|default:0}
              {if $ratingTotal>0 && $productReviewsCount>0}
                {assign var="avgUsrRating" value=$ratingTotal/$productReviewsCount}
	        {assign var="avgUsrRating" value=$avgUsrRating|round:2}
              {else}
                {assign var="avgUsrRating" value=0}
              {/if}
              {assign var="newKey" value=$key1+1}
              {if $newKey%2 eq 0}
                 {assign var="proHeadClass" value="subPro-odd-bg"}
              {else}
                 {assign var="proHeadClass" value=""}
              {/if}
              {assign var="subproCount" value=$product['subProducts']|count+1}
              <tr class="subPro-head {$proHeadClass}">
                <td align="left" valign="middle" class="headerPro" rowspan="{$subproCount}">
		    {html->anchor href="product/show/id/{$product.baseProductID}/" caption=$product.productTitle}
		</td>
                <td align="left" valign="middle" class="headerPro">
		    {$product.businessName}	
		</td>
                <td align="left" valign="middle">
		    {$product.productOptionProductPrice}	
		</td>
                <td align="left" valign="middle">
                    {if $avgRating>0} {$avgRating|number_format:2}/5 {else} {$language.lblNoRating} {/if}
		</td>
                <td align="left" valign="middle">
                    {if $avgUsrRating>0} {$avgUsrRating|number_format:2}/5 {else} {$language.lblNoRating} {/if}
		</td>
               
                <td align="left" valign="middle">
		    {$product.productCommissionRate}	
		</td>
                 {*<td align="left" valign="middle">
                    {$product.optionSKU} - {$product.baseProductID}	
                </td>*}
                <td align="left" valign="middle">{html->anchor href="buybox/setBaseProduct/id/{$buyboxID}/productID/{$product.productID}/" 
class="prd-status-active icon-set"}</td>
              </tr>
              
                   {foreach from=$product['subProducts'] item="subProducts" key="key2"}
                        {assign var="subbuyboxDetailsID" value=$subProducts.buyboxDetailsID}
                        {assign var="subbuyboxID" value=$subProducts.buyboxID}
                        {assign var="subProCount" value=$product['subProducts']|count}
                        {if $subProCount eq $key2+1}
                            {assign var="innerProClass" value="pro-border-bottom"}
                        {else}
                            {assign var="innerProClass" value=""}
                        {/if}
                        {if $subProducts['busRating'].ratingTotal>0 && $subProducts['busRating'].ratingCount>0}
                           {assign var="subavgRating" value=$subProducts['busRating'].ratingTotal/$subProducts['busRating'].ratingCount}
                        {else}
                           {assign var="subavgRating" value=0}
                        {/if}

                        {assign var="subratingTotal" value=$subProducts['userRating'].ratingTotal|default:''}
                        {assign var="subproductReviewsCount" value=$subProducts['userRating'].productReviewsCount|default:0}
                        {if $subratingTotal>0 && $subproductReviewsCount>0}
                            {assign var="subavgUsrRating" value=$subratingTotal/$subproductReviewsCount}
                            {assign var="subavgUsrRating" value=$subavgUsrRating|round:2}
                        {else}
                            {assign var="subavgUsrRating" value=0}
                        {/if}
                        
                        <tr class="subPro {$proHeadClass}">
                            <td align="left" valign="middle" class="{$innerProClass} innerPro">
                                {$subProducts.businessName}	
                            </td>
                            <td align="left" valign="middle">
                                {$subProducts.productOptionProductPrice}	
                            </td>
                            <td align="left" valign="middle">
                                {if $subavgRating>0} {$subavgRating|number_format:2}/5 {else} {$language.lblNoRating} {/if}
                            </td>
                            <td align="left" valign="middle">
                                {if $subavgUsrRating>0} {$subavgUsrRating|number_format:2}/5 {else} {$language.lblNoRating} {/if}
                            </td>
                            <td align="left" valign="middle">
                                {$subProducts.productCommissionRate}	
                            </td>
                            
                             {*<td align="left" valign="middle">
                                {$subProducts.optionSKU} - {$subProducts.productID}	
                            </td>*}
                           
                            <td align="left" valign="middle">
                                {html->anchor href="buybox/setBaseProduct/id/{$subbuyboxID}/productID/{$subProducts.productID}/" class="prd-status-inactive icon-set"}</td>
                          </tr>
              
                   {/foreach}    
              {/foreach}
            </table>
            </div>
            
            {else}
            <div id="common_message"  class="message_info"> {$language.msgNoRecords}</div>
            {/if}
          <!--End:Table Listing--> 
    </div>
    <!--End: left Block-->
    <div class="clear"></div>
    </div>
  </div>
  <!--***********************************************************************END CONTAINER SECTION******************************************************--> 
  <!--End:Content Container--> 
  {include file='CommonBottom.tpl'} 
</div>
{include file='CommonJavaScriptBottom.tpl'} 
<!--End:Outer Container-->
{html->messages_script id="common_message"} 
 
<script type="text/javascript" src="{$common_js}/date.js"></script>
<script type="text/javascript" src="{$view_javascript}/table.plugin.js"></script>
<script type="text/javascript" src="{$view_javascript}/daterangepicker.jQuery.js"></script>
<script type="text/javascript" >
var msgSelectSearchCriteria="{$language.msgSelectSearchCriteria}";
var lblSelectAction ='{$language.lblSelectAction}';
var msgSelectItem="{$language.msgSelectItem}";
var msgConfirmDelete="{$language.msgConfirmDelete}";
</script>
</body>
</html>
