[ Index ]

MailPress 544

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

title

Body

[close]

/mp-includes/class/options/dashboard/widgets/ -> mails_sent.php (source)

   1  <?php
   2  class MP_Dashboard_mails_sent extends MP_dashboard_widget_
   3  {
   4      var $id = 'mp_mails_sent';
   5  
   6  	function widget()
   7      {
   8          global $wpdb, $wp_locale;
   9  
  10          $dend    = date('Y-m-d');                         $y = substr($dend,0,4); $m = substr($dend,5,2); $d = substr($dend,8,2);
  11          $dbeg = date('Y-m-d',mktime(0, 0, 0, $m, $d-66, $y)); $y = substr($dbeg,0,4);    $m = substr($dbeg,5,2); $d = substr($dbeg,8,2);
  12  
  13          $mails = $wpdb->get_results( $wpdb->prepare( "SELECT sdate, sum(scount) AS count FROM $wpdb->mp_stats WHERE stype = 't' AND sdate BETWEEN %s AND %s GROUP BY sdate ORDER BY sdate;", $dbeg, $dend ) );
  14          if (!$mails) return;
  15          foreach($mails as $mail) $Ms[$mail->sdate] = $mail->count;
  16  
  17          $chxl_y = 0;
  18          $chxl_day = $chxl_month = $chxl_year = $chdM = array();
  19  
  20          $time = $dbeg; $wy = $y; $wm = $m; $wd = $d;
  21  
  22          do 
  23          {
  24          // data
  25              $chdM[] = (isset($Ms[$time])) ? $Ms[$time] : -1;
  26  
  27          // axis
  28              // y
  29              $chxl_y = (isset($Ms[$time])) ? max($Ms[$time], $chxl_y) : $chxl_y;
  30  
  31              // x
  32              if     (empty($chxl_year))                         $chxl_year[] = $wy;
  33              elseif ('0101' == substr($time,5,2) . substr($time,8,2))     $chxl_year[] = substr($time,0,4);
  34              else                                         $chxl_year[] = '';
  35  
  36              $chxl_month[] = ('15' == substr($time,8,2)) ? $wp_locale->get_month_abbrev($wp_locale->get_month(substr($time,5,2))) : '';
  37  
  38              if         ('01' == substr($time,8,2))     $chxl_day[] = '01';
  39              elseif     ('15' == substr($time,8,2))     $chxl_day[] = '15';
  40              else                             $chxl_day[] = '';
  41  
  42              $time = date('Y-m-d',mktime(0, 0, 0, $m, ++$d, $y));
  43          } while ($time <= $dend);
  44  
  45          $args = array();
  46          $args['cht']  = 'bvg';
  47          $args['chs']  = $this->widget_size('570x330');
  48          $args['chxt'] = 'x,y,x,x';
  49          $args['chxl'] = '0:|' . join('|', $chxl_day) . '|1:||' . $chxl_y . '|2:|' . join('|', $chxl_month) . '|3:|' . join('|', $chxl_year);
  50          $args['chds'] = "0,{$chxl_y}";
  51          $args['chbh'] = $this->bar_size(7) . ',1,1';
  52          $args['chco'] = '4d89f9';
  53          $args['chd']  = 't:' . join(',', $chdM);
  54          $url = esc_url(add_query_arg($args, $this->url));
  55  
  56  ?>
  57  <div style='text-align:center;'>
  58  <img style='width:100%;' src="<?php echo $url; ?>" alt="<?php _e( 'Mails - send', MP_TXTDOM ); ?>" /></div>
  59  <?php
  60      }
  61  }
  62  new MP_Dashboard_mails_sent(__( 'MailPress - Mails sent', MP_TXTDOM ));


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