<!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.lblBusiness} : {$language.lblAnalyticsReport} : {$language.lblLocationReport}</title>
{include file='CommonJavaScript.tpl'}
{include file='CommonStyles.tpl'}
<link rel="stylesheet" type="text/css" href="{$view_styles}/listing.css" />
<link rel="stylesheet" type="text/css" href="{$view_styles}/analytics.css" />
<link rel="stylesheet" type="text/css" href="{$view_styles}/right-menu.css" />
<link rel="stylesheet" type="text/css" href="{$view_styles}/chosen.css" />
{*<link rel="stylesheet" type="text/css" href="{$view_styles}/analytics/analytics-inner.css" />*}
<link href="{$view_styles}/jqueryui.plugin.css" rel="stylesheet" type="text/css" media="screen" />
<link rel="stylesheet" type="text/css" href="{$view_styles}/analytics/ui.daterangepicker.css" />
<link rel="stylesheet" type="text/css" href="{$view_styles}/analytics/jquery-ui-1.8.19.custom.css" />
{include file='CommonCustomStyles.tpl'}   
{form->basepath_script}
{form->rootpath_script}

</head>
<body class="{$languageDirection}">
<div class="outer" id="main">
  {include file='CommonHeader.tpl'} 
  <!--End:Header Container--> 
  <!--*****************************************END HEADER CONTAINER*******************************************-->
   <div class="content-wrapper">
    <!-- left wrapper starts-->
    <div class="container-fluid">
    <div class="content_wrapper">     
      
      <!-- Inner Content Container starts-->
      <div class="container-section status-01">   
	  <!-- Search container starts -->
          <h3 class="border-bottom">{$language.lblLocationReport}</h3>
          {form->start name="frmSearchLocation" action="" method="post"}
      <div class="search_container content-block"> 
          <div class="inner">
             <div class="row">
            	<div class="form-group col-xs-12 col-sm-3">
                	<label class="label-field01">{$language.lblGender}</label>
                    <span class="form-field01 heightauto ">{form->hidden id="cityNameString" class="form-control"  name="cityNameString" value=$cityNameString}
                      {form->select class="chzn-select form-control hidden-chzn-choices" id="searchGender"  name="searchGender" options="Male->{$language.lblMale}~*Female->{$language.lblFemale}~*Not Specified->{$language.lblNotSpecified}" multiple="multiple" style="width:100%;" value=$searchGenderSelect} </span>
                 </div>
                
              <div class="form-group col-xs-12 col-sm-3">
                	<label class="label-field01">{$language.lblAge}</label>
                 <span class="form-field01 heightauto"> 
                {form->select id="searchAge"  name="searchAge" class="chzn-select form-control"  multiple="multiple" options="below17->0-17~*18-24->18-24~*25-34->25-34~*35-54->35-54~*above55->{$language.lbl55plus}~*notage->{$language.lblNotSpecified}" style="width:100%;" value=$searchAgeSelect}
                  </span></div>
                
                
               <div class="form-group col-xs-12 col-sm-3">
                	<label class="label-field01">{$language.lblDate}</label>
                <span class="form-field01"> 
                <div class="text-box-div-date">
                       {form->textbox name="date" readonly="readonly" class="date-field form-control"}
                      </div>
                   </span></div>
                 <div class="col-xs-12">
                	<label class="label-field01">&nbsp;</label>
                  {form->submit name="submitSearch" id="submit" class="btn btn-primary btn-sm"   value=$language.lblSearch}
                  {html->anchor href="/analytics/location/" class="action-link" content=$language.lblListAll}
                 </div>
                 </div>
                
            </div>
           {form->close}
            
          </div>
      <!-- Search container ends --> 
      
      <!---Grid starts------>
      {if $resultLog|@count>0} 
            <div class="box-content row">
                 <ul class="clearfix col-xs-12 col-sm-10 col-md-6">
                  <li class="col-xs-12 col-sm-4">
                     <div class="grey-box-content">
                       {$language.lblVisits} 
                       <p>{$resultLogTotal.totalCustomers}</p>                      
                     </div>
                   </li>
                 
                   <li class="col-xs-12 col-sm-4">
                     <div class="grey-box-content">
                      {$language.lblNewVisits}
                       <p>{$resultLogTotal.newVisit}</p>                       
                     </div>
                   </li>  
                   <li class="col-xs-12 col-sm-4">
                     <div class="grey-box-content">
                       {$language.lblReturningVisits}
                       <p>{$resultLogTotal.returnVisit}</p>                       
                     </div>
                   </li>   
                                     
                 </ul>
              </div>
              
    {assign var="cityClass" value="sort"}
    {assign var="visitClass" value="sort"}               
    {assign var="orderClass" value="sort"}
    {assign var="orderAmountClass" value="sort"}

    {if $sortByOption=='cityName'}                
    {assign var="cityClass" value="sort"|cat:$sortByOrderCity}                
    {elseif $sortByOption=='user'}
    {assign var="visitClass" value="sort"|cat:$sortByOrderVisit}               
    {elseif $sortByOption=='orderCount'}
    {assign var="orderClass" value="sort"|cat:$sortByOrderOrder}   
    {elseif $sortByOption=='orderAmount'}
    {assign var="orderAmountClass" value="sort"|cat:$sortByOrderOrderAmount}  
    {/if}           
              
    <div class="grid_table01">
       <table width="100%" border="0" cellspacing="0" cellpadding="0" >           
            <thead>
              <tr>
                <th align="left" valign="top" width="40%"  class={$cityClass} >
                {html->anchor href="/analytics/location/"|cat:$link|cat:"sortby/cityName/orderby/$sortByOrderCity/" title=$language.lblLocation 	content=$language.lblLocation}
                </th> 
                <th align="left" valign="top"  class={$visitClass}>
                {html->anchor href="/analytics/location/"|cat:$link|cat:"sortby/user/orderby/$sortByOrderVisit/" title=$language.lblVisit 	content=$language.lblVisits}
                </th>
                <th align="left" valign="top"  class={$orderClass}>
                {html->anchor href="/analytics/location/"|cat:$link|cat:"sortby/orderCount/orderby/$sortByOrderOrder/" title=$language.lblOrders content=$language.lblOrders}
                </th> 
                 <th align="left" valign="top"  class={$orderAmountClass}>
                {html->anchor href="/analytics/location/"|cat:$link|cat:"sortby/orderAmount/orderby/$sortByOrderOrderAmount/" title=$language.lblOrderTotalAmount content=$language.lblOrderTotalAmount}
                </th> 
              </tr>
            </thead>
            <tbody>
             {foreach from=$resultLog item="log" key="key1"}                 
              <tr >
                <td align="left" valign="top">{$log.cityName}, {$log.stateName|default:''}, {$log.countryName}</td>  
              <td align="left" valign="top">
                    <span class="expand-span expandable" id="cat-2">
                    <a href="javascript:void(0);"> {$log.users|@count}</a>
                    </span>
                 </td>
                <td align="left" valign="top">{$log.orderCount}</td>
                <td align="left" valign="top">{$log.orderAmount|price}</td>
              </tr>
                <tr class="detailview" style="display:none;">
              <td class="visits1">&nbsp;</td>
                <td align="left" valign="top" colspan="8" class="visits" >
                    {assign var="newVisit" value=0}
                    {assign var="retVisit" value=0}
                     {foreach from=$log['users'] item="user"}   
                         {if $user==1}
                            {assign var="newVisit" value=$newVisit+1} 
                         {else}
                              {assign var="retVisit" value=$retVisit+1}
                         {/if}
                      {/foreach}                	
                  	<strong>{$language.lblNewVisits}: <span id={$key1|cat:"_newVisit"}>{$newVisit}</span></strong>
                   	&nbsp; &nbsp; &nbsp;   
                   	<strong>{$language.lblReturningVisits} : <span id={$key1|cat:"_returningVisit"}>{$retVisit}</span></strong></td>
                </tr>
             {/foreach}                
            </tbody>
          </table>
          </div>
         
    {else}
    <div  class="message_info">{$language.msgNoRecords}</div>
        <div class="clear"></div>
    {/if}
      <!---Grid ends--->
      </div>
         
      <!-- Inner Content Container ends-->
      <div class="clear"></div>
    </div>
    </div>
      
    <!-- left wrapper ends-->
    <!-- right side bar starts-->
    <div class="right-sidebar">
    <div class="side_wrapper">    
    <!-- right side menu starts-->
    {*{include file='AnalyticsSideMenu.tpl'} *}
    <!-- right side menu ends-->
    </div>
    </div>
    <!-- right side bar ends-->
    <div class="clear"></div>
  </div>
  <!--End:Content Container--> 
  {include file='CommonFooter.tpl'}
</div>
<!--End:Outer Container--> 
{include file='CommonJavaScriptBottom.tpl'} 
<script type="text/javascript" src="{$common_js}/date.js"></script>
<script type="text/javascript" src="{$common_js}/jquery-ui-1.10.2.custom.min.js"></script>
<script type="text/javascript" src="{$view_javascript}/analytics/daterangepicker.jQuery.js"></script>
<script type="text/javascript" src="{$view_javascript}/analyticsDetail.page.js"></script>
<script type="text/javascript" src="{$view_javascript}/chosen.jquery.min.js"></script>


<script type="text/javascript">
     var lblNoMatch   =   '{$language.lblNoMatch}';
 {literal}
 //$(".chzn-select").attr("data-placeholder",lblSelectSomeOption);
 $(".chzn-select").chosen(); $(".chzn-single").chosen({allow_single_deselect:true}); 
 //expandable collapsable table  :: Starts
 {/literal}
 
 $(document).ready(function(){
$('.side_wrapper div ul li a[rel=analytics_location]').addClass('selected');
$('.side_wrapper div ul li a[rel=analytics_overview]').addClass('removeborder');
 {literal}
$(document).on('click',".expandable",function(){
		$(".detailview").hide();
		$("td").removeClass("selectedtd");
		$(".expand-span").removeClass("collapsable").addClass("expandable");
		$(this).closest("tr").next(".detailview").show();
		$(this).removeClass("expandable").addClass("collapsable");
		$(this).parent("td").addClass("selectedtd")
	});	
	$(document).on('click',".collapsable",function(){
		$(this).closest("tr").next(".detailview").hide();
		$(this).removeClass("collapsable").addClass("expandable");
		$(this).parent("td").removeClass("selectedtd")
	});
	
{/literal}
});		
ajaxcall();


</script>
<script>
$(document).ready(function(){
 
       $(".choosen").chosen(); 
}); 
</script>

{html->messages_script id="common_message"}

</body>
</html>