[ Index ]

MailPress 544

[ Index ]     [ Classes ]     [ Functions ]     [ Variables ]     [ Constants ]     [ Statistics ]    

title

Body

[close]

/mp-includes/class/options/tracking/metaboxes/mail/ -> m009.php (source)

   1  <?php
   2  class MP_Tracking_metabox_m009 extends MP_tracking_metabox_
   3  {
   4      var $id    = 'm009';
   5      var $context= 'normal';
   6      var $file     = __FILE__;
   7      var $url     = 'http://chart.apis.google.com/chart';
   8  
   9  	function meta_box($mail)
  10      {
  11          global $wp_locale, $wpdb;
  12          $dend   = $wpdb->get_var( $wpdb->prepare( "SELECT max(DATE(tmstp)) FROM $wpdb->mp_tracks WHERE mail_id = %d ;", $mail->id) ); $y = substr($dend,0,4); $m = substr($dend,5,2); $d = substr($dend,8,2);
  13          $dbeg = date('Y-m-d', mktime(0, 0, 0, $m, $d-65, $y));                                                 $y = substr($dbeg,0,4);    $m = substr($dbeg,5,2); $d = substr($dbeg,8,2);
  14  
  15          $tracks = $wpdb->get_results( $wpdb->prepare( "SELECT DATE(tmstp) as tmstp, track, count(*) as count FROM $wpdb->mp_tracks WHERE mail_id = %d AND DATE(tmstp) BETWEEN %s AND %s GROUP BY 1, 2 ORDER BY 1 DESC, 2 DESC ;", $mail->id, $dbeg, $dend) );
  16          if (!$tracks) return;
  17  
  18          foreach($tracks as $track)
  19          {
  20              $time = $track->tmstp;
  21              if ( MailPress_tracking_openedmail == $track->track )
  22              {
  23                  if (isset($Mo[$time]))     $Mo[$time] += $track->count;
  24                  else                $Mo[$time]  = $track->count;
  25              }
  26              else
  27              {
  28                  if (isset($Mc[$time]))     $Mc[$time] += $track->count;
  29                  else                $Mc[$time]  = $track->count;
  30              }
  31          }
  32  
  33          $chxl_y = 0;
  34          $chxl_day = $chxl_month = $chxl_year = $chdMo = $chdMc = array();
  35  
  36          $time = $dbeg; $wy = $y; $wm = $m; $wd = $d;
  37          do 
  38          {
  39          // data
  40              $chdMo[] = (isset($Mo[$time])) ? $Mo[$time] : -1;
  41              $chdMc[] = (isset($Mc[$time])) ? $Mc[$time] : -1;
  42  
  43          // axis
  44              // y
  45              $chxl_y = (isset($Mo[$time])) ? max($Mo[$time], $chxl_y) : $chxl_y;
  46              $chxl_y = (isset($Mc[$time])) ? max($Mc[$time], $chxl_y) : $chxl_y;
  47  
  48              // x
  49              if     (empty($chxl_year))                         $chxl_year[] = $wy;
  50              elseif ('0101' == substr($time,5,2) . substr($time,8,2))     $chxl_year[] = substr($time,0,4);
  51              else                                         $chxl_year[] = '';
  52  
  53              $chxl_month[] = ('15' == substr($time,8,2)) ? $wp_locale->get_month_abbrev($wp_locale->get_month(substr($time,5,2))) : '';
  54  
  55              if         ('01' == substr($time,8,2))     $chxl_day[] = '01';
  56              elseif     ('15' == substr($time,8,2))     $chxl_day[] = '15';
  57              else                             $chxl_day[] = '';
  58  
  59              $time = date('Y-m-d',mktime(0, 0, 0, $m, ++$d, $y));
  60          } while ($time <= $dend);
  61  
  62          $args = array();
  63          $args['cht']  = 'bvs';
  64          $args['chs']  = '570x330';
  65          $args['chxt'] = 'x,y,x,x';
  66          $args['chxl'] = '0:|' . join('|', $chxl_day) . '|1:||' . $chxl_y . '|2:|' . join('|', $chxl_month) . '|3:|' . join('|', $chxl_year);
  67          $args['chds'] = "0,{$chxl_y}";
  68          $args['chdlp']= 'b';
  69          $args['chdl'] = __('Opened', MP_TXTDOM) . '|' . __('Clicks', MP_TXTDOM);
  70          $args['chbh'] = '7,1,1';
  71          $args['chco'] = '84D1F5,D54E21';
  72          $args['chm']  = 'o,D54E21,1,,7,2';
  73  
  74          $args['chd']  = 't1:' . join(',', $chdMo) . '|' . join(',', $chdMc);
  75          $url = esc_url(add_query_arg($args, $this->url));
  76  
  77  ?>
  78  <div style='text-align:center;'>
  79  <img style='width:100%;' src="<?php echo $url; ?>" alt="<?php _e( 'Mails - send', MP_TXTDOM ); ?>" /></div>
  80  <?php
  81      }
  82  }
  83  new MP_Tracking_metabox_m009(__('Opened, Clicks/day chart', MP_TXTDOM));


Generated: Thu Apr 28 18:38:52 2016 Cross-referenced by PHPXref 0.7.1