<?php defined('MW_PATH') || exit('No direct script access allowed');

/**
 * This file is part of the MailWizz EMA application.
 * 
 * @package MailWizz EMA
 * @author Serban George Cristian <cristian.serban@mailwizz.com> 
 * @link http://www.mailwizz.com/
 * @copyright 2013-2014 MailWizz EMA (http://www.mailwizz.com)
 * @license http://www.mailwizz.com/license/
 * @since 1.0
 */
 
?>

<div class="callout">
    <?php
    $text = 'This page shows the urls the subscriber <span class="badge">{email}</span> clicked on.<br />
    If the subscriber clicked same link twice, you will see it only once and you will see the number of clicks it received.<br />
    If you need to see all the clicks and their click time for this subscriber, please click 
    <a href="{href}">here</a>.';
    echo Yii::t('campaign_reports', StringHelper::normalizeTranslationString($text), array(
        '{email}'   => $subscriber->email,
        '{href}'    => $this->createUrl('campaign_reports/click_by_subscriber', array('campaign_uid' => $campaign->campaign_uid, 'subscriber_uid' => $subscriber->subscriber_uid)),
    ));
    ?>
</div>
        

<div class="panel panel-default">
    <div class="panel-heading">
        <div class="pull-left">
            <h3 class="panel-title">
                <span class="glyphicon glyphicon-list-alt"></span> <?php echo $pageHeading;?>
            </h3>
        </div>
        <div class="pull-right">
            <?php echo CHtml::link(Yii::t('campaign_reports', 'Campaign overview'), array('campaigns/overview', 'campaign_uid' => $campaign->campaign_uid), array('class' => 'btn btn-default btn-xs', 'title' => Yii::t('campaign_reports', 'Back to campaign overview')));?>
            <?php echo CHtml::link(Yii::t('campaign_reports', 'All clicks'), array('campaign_reports/click', 'campaign_uid' => $campaign->campaign_uid), array('class' => 'btn btn-default btn-xs', 'title' => Yii::t('campaign_reports', 'Back to all clicks report')));?>
            <?php echo CHtml::link(Yii::t('campaign_reports', 'All subscriber clicks'), array('campaign_reports/click_by_subscriber', 'campaign_uid' => $campaign->campaign_uid, 'subscriber_uid' => $subscriber->subscriber_uid), array('class' => 'btn btn-default btn-xs', 'title' => Yii::t('campaign_reports', 'Back to all subscriber clicks')));?>
        </div>
        <div class="clearfix"><!-- --></div>
    </div>
    <div class="panel-body">

        <div class="table-responsive">
        <?php 
        $this->widget('zii.widgets.grid.CGridView', array(
            'id'                => $model->modelName.'-grid',
            'dataProvider'      => $dataProvider,
            'filter'            => null,
            'filterPosition'    => 'body',
            'filterCssClass'    => 'grid-filter-cell',
            'itemsCssClass'     => 'table table-bordered table-hover table-striped',
            'selectableRows'    => 0,
            'enableSorting'     => false,
            'cssFile'           => false,
            'pagerCssClass'     => 'pagination pull-right',
            'pager'             => array(
                'class'         => 'CLinkPager',
                'cssFile'       => false,
                'header'        => false,
                'htmlOptions'   => array('class' => 'pagination')
            ),
            'columns'=>array(
                
                array(
                    'name'  => 'url.destination',
                    'value' => '$data->url->getDisplayGridDestination()',
                    'type'  => 'raw',
                    'htmlOptions' => array('style' => 'max-width:250px;word-wrap:break-word;'),
                ),
                
                array(
                    'name'  => 'clicked_times',
                    'value' => '$data->counter',
                ),
                
                array(
                    'name'  => 'ip_address',
                    'value' => 'CHtml::link($data->getIpWithLocationForGrid(), "http://who.is/whois-ip/ip-address/".$data->ip_address, array("target" => "_blank"))',
                    'type'  => 'raw',
                ),
                
                array(
                    'name'  => 'user_agent',
                    'value' => 'CHtml::link($data->user_agent, "http://user-agent-string.info/?Fuas=".urlencode($data->user_agent), array("target" => "_blank"))',
                    'type'  => 'raw',
                    'htmlOptions' => array('style' => 'max-width:220px;word-wrap:break-word;'),
                ),

                array(
                    'name'  => 'date_added',
                    'value' => '$data->dateAdded',
                ),
            ),
        )); ?>
        </div>    
    </div>
</div>