[ Index ]

MailPress 7.0.1

[ 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 ) );
  13                  if ( !$dend ) return;
  14                  
  15          $m = substr( $dend,5,2 ); 
  16          $d = substr( $dend,8,2 );
  17          $y = substr( $dend,0,4 ); 
  18          $dbeg = date( 'Y-m-d', mktime( 0, 0, 0, $m, $d-65, $y ) );
  19                  
  20          $m = substr( $dbeg,5,2 );
  21          $d = substr( $dbeg,8,2 );
  22          $y = substr( $dbeg,0,4 ); 
  23  
  24          $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 ) );
  25          if ( !$tracks ) return;
  26  
  27          foreach( $tracks as $track )
  28          {
  29              $time = $track->tmstp;
  30              if ( MailPress_tracking_openedmail == $track->track )
  31              {
  32                  if ( isset( $Mo[$time] ) )     $Mo[$time] += $track->count;
  33                  else                $Mo[$time]  = $track->count;
  34              }
  35              else
  36              {
  37                  if ( isset( $Mc[$time] ) )     $Mc[$time] += $track->count;
  38                  else                $Mc[$time]  = $track->count;
  39              }
  40          }
  41  
  42          $chxl_y = 0;
  43          $chxl_day = $chxl_month = $chxl_year = $chdMo = $chdMc = array();
  44  
  45          $time = $dbeg; $wy = $y; $wm = $m; $wd = $d;
  46          do 
  47          {
  48          // data
  49              $chdMo[] = ( isset( $Mo[$time] ) ) ? $Mo[$time] : -1;
  50              $chdMc[] = ( isset( $Mc[$time] ) ) ? $Mc[$time] : -1;
  51  
  52          // axis
  53              // y
  54              $chxl_y = ( isset( $Mo[$time] ) ) ? max( $Mo[$time], $chxl_y ) : $chxl_y;
  55              $chxl_y = ( isset( $Mc[$time] ) ) ? max( $Mc[$time], $chxl_y ) : $chxl_y;
  56  
  57              // x
  58              if     ( empty( $chxl_year ) )                         $chxl_year[] = $wy;
  59              elseif ( '0101' == substr( $time,5,2 ) . substr( $time,8,2 ) )     $chxl_year[] = substr( $time,0,4 );
  60              else                                         $chxl_year[] = '';
  61  
  62              $chxl_month[] = ( '15' == substr( $time,8,2 ) ) ? $wp_locale->get_month_abbrev( $wp_locale->get_month( substr( $time,5,2 ) ) ) : '';
  63  
  64              if         ( '01' == substr( $time,8,2 ) )     $chxl_day[] = '01';
  65              elseif     ( '15' == substr( $time,8,2 ) )     $chxl_day[] = '15';
  66              else                             $chxl_day[] = '';
  67  
  68              $time = date( 'Y-m-d',mktime( 0, 0, 0, $m, ++$d, $y ) );
  69          } while ( $time <= $dend );
  70  
  71          $args = array();
  72          $args['cht']  = 'bvs';
  73          $args['chs']  = '570x330';
  74          $args['chxt'] = 'x,y,x,x';
  75          $args['chxl'] = '0:|' . join( '|', $chxl_day ) . '|1:||' . $chxl_y . '|2:|' . join( '|', $chxl_month ) . '|3:|' . join( '|', $chxl_year );
  76          $args['chds'] = "0,{$chxl_y}";
  77          $args['chdlp']= 'b';
  78          $args['chdl'] = __( 'Opened', 'MailPress' ) . '|' . __( 'Clicks', 'MailPress' );
  79          $args['chbh'] = '7,1,1';
  80          $args['chco'] = '84D1F5,D54E21';
  81          $args['chm']  = 'o,D54E21,1,,7,2';
  82  
  83          $args['chd']  = 't1:' . join( ',', $chdMo ) . '|' . join( ',', $chdMc );
  84          $url = esc_url( add_query_arg( $args, $this->url ) );
  85  
  86          $out  = '<div style="text-align:center;"><img style="width:100%;" src="' . $url . '" alt="' . esc_attr__( 'Mails - send', 'MailPress' ) . '" /></div>';
  87  
  88          echo $out;
  89      }
  90  }
  91  new MP_Tracking_metabox_m009( __( 'Opened, Clicks/day chart', 'MailPress' ) );


Generated: Mon Jan 28 00:07:10 2019 Cross-referenced by PHPXref 0.7.1