コード例 #1
0
ファイル: debug.php プロジェクト: rbredow/allyzabbacart
              <input type="hidden" name="cart66-action" value="check followup emails" id="cart66-action" />
              <input type="submit" value="<?php 
_e('Send Followup Emails', 'cart66');
?>
" class="button-secondary" />
            </form>
          </td>
        </tr>
        <tr valign="top">
          <th scope="row"><?php 
_e('Prune Pending Orders Last Checked', 'cart66');
?>
</th>
          <td>
            <?php 
echo Cart66Setting::getValue('daily_prune_pending_orders_last_checked') ? Cart66Common::getElapsedTime(date('Y-m-d H:i:s', Cart66Setting::getValue('daily_prune_pending_orders_last_checked'))) : __("Never", "cart66");
?>
            <form action="" method="post" style="display:inline-block">
              <input type="hidden" name="cart66-action" value="prune pending orders" id="cart66-action" />
              <input type="submit" value="<?php 
_e('Prune Pending Orders', 'cart66');
?>
" class="button-secondary" />
            </form>
          </td>
        </tr>
        <tr valign="top">
          <th scope="row"><?php 
_e('Next Scheduled Cron Check', 'cart66');
?>
</th>
コード例 #2
0
    public static function cart66_statistics_widget()
    {
        function totalFromRange($start, $end)
        {
            global $wpdb;
            $tableName = Cart66Common::getTableName('orders');
            $sql = "SELECT sum(total) as total from {$tableName} where ordered_on > '{$start}' AND ordered_on < '{$end}'";
            $result = $wpdb->get_row($sql, ARRAY_A);
            $output = $result ? (double) $result['total'] : "N/A";
            return $output;
        }
        // TODAY
        $yday = date('Y-m-d 00:00:00', strtotime('yesterday'));
        $dayStart = date('Y-m-d 00:00:00', strtotime('today'));
        $dayEnd = date('Y-m-d 00:00:00', strtotime('tomorrow'));
        $mdayStart = date('Y-m-01 00:00:00', strtotime('today'));
        $mdayEnd = date('Y-m-01 00:00:00', strtotime('next month'));
        $today_total = totalFromRange($dayStart, $dayEnd);
        $yesterday_total = totalFromRange($yday, $dayStart);
        $month_total = totalFromRange($mdayStart, $mdayEnd);
        $total_product_sales = Cart66DataTables::productsSearch();
        $total_sales_amount = Cart66DataTables::totalSalesForMonth($total_product_sales);
        $daily_avg = ($month_total - $today_total) / date('j', strtotime('yesterday'));
        //number_format($month_total/date("j"),2);
        $total_days = date('t', strtotime('now'));
        $est_month = $total_days * $daily_avg;
        ?>
    <div class="cart66Tabbed">
      <ul class="tabs">
        <li class="t1"><a class="t1 tab" href="javascript:void(0)"><?php 
        _e('Summary', 'cart66');
        ?>
</a></li>
        <li class="t2"><a class="t2 tab" href="javascript:void(0)"><?php 
        _e('Today/Yesterday', 'cart66');
        ?>
</a></li>
        <li class="t3"><a class="t3 tab" href="javascript:void(0)"><?php 
        echo date("F, Y", strtotime("now"));
        ?>
</a></li>
        <li class="t4"><a class="t4 tab" href="javascript:void(0)"><?php 
        _e('Daily Average', 'cart66');
        ?>
</a></li>
        <li class="t5"><a class="t5 tab" href="javascript:void(0)"><?php 
        _e('Estimate', 'cart66');
        ?>
</a></li>
      </ul>
      <div class="loading">
        <h2 class="center"><?php 
        _e('loading...', 'cart66');
        ?>
</h2>
      </div>
      <div class="t1 pane">
        <table id="statSummary" cellspacing="0" cellpadding="0">
        <tfoot>
        <tr>
          <td>
           <?php 
        _e('Last Updated', 'cart66');
        ?>
:
          </td>
          <td class="right">
            <?php 
        echo date(get_option('date_format'), Cart66Common::localTs());
        ?>
 <?php 
        echo date(get_option('time_format'), Cart66Common::localTs());
        ?>
          </td>
        </tr>
        </tfoot>
          <tbody>
          <tr class="t4 tab summaryDetails">
            <td>
             <?php 
        echo date('F');
        _e(' Daily Average', 'cart66');
        ?>
:
            </td>
            <td class="right">
             <a class="t4 tab" href="javascript:void(0)"><?php 
        echo Cart66Common::currency($daily_avg);
        ?>
</a>
            </td>
          </tr>
          <tr class="t2 tab summaryDetails">
            <td>
              <?php 
        _e('Today\'s Total', 'cart66');
        ?>
:
            </td>
            <td class="right">
              <a class="t2 tab" href="javascript:void(0)"><?php 
        echo Cart66Common::currency($today_total);
        ?>
</a>
            </td>
          </tr>
          <tr class="t2 tab summaryDetails">
            <td>
              <?php 
        _e('Yesterday\'s Total', 'cart66');
        ?>
:
            </td>
            <td class="right">
              <a class="t2 tab" href="javascript:void(0)"><?php 
        echo Cart66Common::currency($yesterday_total);
        ?>
</a>
            </td>
          </tr>
          <tr class="t3 tab summaryDetails">
            <td>
              <?php 
        echo date("F", strtotime("now"));
        ?>
 <?php 
        _e('Total', 'cart66');
        ?>
:
            </td>
            <td class="right">
             <a class="t3 tab" href="javascript:void(0)"><?php 
        echo Cart66Common::currency($month_total);
        ?>
</a>
            </td>
          </tr>
          <tr class="t5 tab summaryDetails">
            <td>
             <?php 
        _e('Estimated', 'cart66');
        ?>
 <?php 
        echo date("F", strtotime('now'));
        ?>
 <?php 
        _e('Total', 'cart66');
        ?>
:
            </td>
            <td class="right">
             <a class="t5 tab" href="javascript:void(0)"><?php 
        echo Cart66Common::currency($est_month);
        ?>
</a>
            </td>
          </tr>
          </tbody>
        </table>
      </div>
      <div class="t2 pane">
        <table id="dayStats" cellpadding="0" cellspacing="0">
          <tr class="summaryDetails dayStats">
            <td>
              <?php 
        _e('Today\'s Total', 'cart66');
        ?>
: <strong><?php 
        echo Cart66Common::currency($today_total);
        ?>
</strong>
            </td>
            <td class="right">
              <?php 
        _e('Yesterday\'s Total', 'cart66');
        ?>
: <strong><?php 
        echo Cart66Common::currency($yesterday_total);
        ?>
</strong>
            </td>
          </tr>
          <tr>
            <td class="wideOrders" colspan="2">
              <table width="100%" id="todaysOrders" cellpadding="0" cellspacing="0">
              <thead>
                <tr>
                  <th colspan="2" class="left"><?php 
        _e('Today\'s Order Details', 'cart66');
        ?>
</th>
                  <th class="right"><?php 
        _e('Order Total', 'cart66');
        ?>
</th>
                </tr>
                </thead>
              <?php 
        $Orders = new Cart66Order();
        $todaysOrders = $Orders->getOrderRows(" WHERE ordered_on > '{$dayStart}' AND ordered_on < '{$dayEnd}' AND id>0", "order by ordered_on DESC");
        if ($todaysOrders) {
            $i = 1;
            ?>
                <tbody>
                  <?php 
            foreach ($todaysOrders as $order) {
                ?>
                    <tr>
                      <td class="rowNumber">
                        <h2><?php 
                echo $i;
                ?>
</h2>
                      </td>
                      <td class="orderInformation">
                        <p><?php 
                echo $order->bill_first_name . " " . $order->bill_last_name;
                ?>
<br>
                          <span class='orderDate'><?php 
                echo Cart66Common::getElapsedTime($order->ordered_on);
                ?>
</span>
                        </p>
                      </td>
                      <td class='right'>
                        <?php 
                echo Cart66Common::currency($order->total);
                ?>
                      </td>
                      <?php 
                $i++;
                ?>
                    </tr>
                  <?php 
            }
            ?>
                </tbody>
                <?php 
        } else {
            ?>
                <tfoot>
                <tr>
                  <td colspan='3'>
                    <h2 class="noOrders"><?php 
            _e('No orders yet today', 'cart66');
            ?>
</h2>
                  </td>
                </tr>
                </tfoot>
              <?php 
        }
        ?>
              </table>
            </td>
          </tr>
        </table>    
      </div>
      <div class="t3 pane">
        <table id="productTable" cellpadding="0" cellspacing="0">
          <tr>
            <thead>
              <tr>
                <th class="left"><?php 
        _e('Product Name', 'cart66');
        ?>
</th>
                <th class="center"><?php 
        _e('Sales', 'cart66');
        ?>
</th>
                <th class="right"><?php 
        _e('Income', 'cart66');
        ?>
</th>
              </tr>
            </thead>
            <tfoot>
              <tr>
                <th class="left"><strong><?php 
        echo date("F, Y", strtotime('now'));
        ?>
</strong></th>
                <?php 
        if (isset($total_sales_amount['total_sales'])) {
            $totalSales = $total_sales_amount['total_sales']['total_quantity'];
            $totalAmount = $total_sales_amount['total_sales']['total_amount'];
        } else {
            $totalSales = '0';
            $totalAmount = '0';
        }
        ?>
                <th class="center"><strong><?php 
        echo $totalSales;
        ?>
</strong></th>
                <th class="right"><strong><?php 
        echo Cart66Common::currency($totalAmount);
        ?>
</strong></th>
              </tr>
            </tfoot>
          </tr>
        </table>
      </div>
      <div class="t4 pane">
        <div>
          <table id="dailyAverage" cellpadding="0" cellspacing="0">
              <?php 
        $column = 0;
        for ($i = 6; $i > 0; $i--) {
            $tmonth_start = date('Y-m-01 00:00:00', strtotime("{$i} months ago"));
            $tmonth_end = date('Y-m-01 00:00:00', strtotime($i - 1 . " months ago"));
            $tmonth_total = totalFromRange($tmonth_start, $tmonth_end);
            $tmonth_days = date('t', strtotime("{$i} months ago"));
            ?>
                <?php 
            if ($tmonth_total != "") {
                ?>
              <thead>
                <tr>
                  <th class="left" colspan="2">
                  <?php 
                echo date('F, Y', strtotime("{$i} months ago"));
                ?>
                  </th>
                </tr>
              </thead>
              <tbody>
                <tr>
                  <td><?php 
                _e('Total Income', 'cart66');
                ?>
:</td>
                  <td class="right"><strong><?php 
                echo Cart66Common::currency($tmonth_total);
                ?>
</strong></td>
                </tr>
                <tr>
                  <td><?php 
                _e('Daily Average', 'cart66');
                ?>
:</td>
                  <td class="right"><strong><?php 
                echo Cart66Common::currency($tmonth_total / $tmonth_days);
                ?>
</strong></td>
                </tr>
                </tbody>
                <?php 
            }
        }
        $ystart = date("Y-01-01 00:00:00");
        $yend = date("Y-01-01 00:00:00", strtotime("next year"));
        $year_total = totalFromRange($ystart, $yend);
        $day_of_year = date('z');
        ?>
              <thead>
                <tr>
                  <th class="left" colspan="2">YTD - <?php 
        echo date('Y');
        ?>
</th>
                </tr>
              </thead>
              <tbody>
                <tr>
                  <td><?php 
        _e('Total Income', 'cart66');
        ?>
:</td>
                  <td class="right"><strong><?php 
        echo Cart66Common::currency($year_total);
        ?>
</strong></td>
                </tr>
                <tr>
                    <td><?php 
        _e('Daily Average', 'cart66');
        ?>
:</td>
                    <td class="right"><strong><?php 
        echo Cart66Common::currency($year_total / $day_of_year);
        ?>
</strong></td>
                </tr>
              </tbody>
          </table>
        </div>
      </div>
      <div class="t5 pane">
        <table id="estimatedSummary" cellspacing="0" cellpadding="0">
          <tbody>
            <tr>
              <td>
                <?php 
        _e('Today', 'cart66');
        ?>
:
              </td>
              <td class="right">
                <?php 
        echo date(get_option('date_format'), strtotime('now'));
        ?>
              </td>
            </tr>
            <tr>
              <td>
                <?php 
        _e('Total Days in', 'cart66');
        ?>
 <?php 
        echo date("F", strtotime('now'));
        ?>
:
              </td>
              <td class="right">
                <?php 
        echo $total_days;
        ?>
              </td>
            </tr>
            <tr>
              <td>
                <?php 
        _e('Remaining Days in', 'cart66');
        ?>
 <?php 
        echo date("F", strtotime('now'));
        ?>
:
              </td>
              <td class="right">
                <?php 
        echo $total_days - date('j', strtotime('now'));
        ?>
              </td>
            </tr>
            <tr>
              <td>
                <?php 
        _e('Estimated Remaining Income', 'cart66');
        ?>
:
              </td>
              <td class="right">
                <?php 
        echo Cart66Common::currency(($total_days - date('j', strtotime('now'))) * $daily_avg);
        ?>
              </td>
            </tr>
          </tbody>
        </table>
      </div>
    </div>
    <script type="text/javascript">
      (function($){
        $(document).ready(function(){
          
          /* API method to get paging information */
          $.fn.dataTableExt.oApi.fnPagingInfo = function ( oSettings )
          {
              return {
                  "iStart":         oSettings._iDisplayStart,
                  "iEnd":           oSettings.fnDisplayEnd(),
                  "iLength":        oSettings._iDisplayLength,
                  "iTotal":         oSettings.fnRecordsTotal(),
                  "iFilteredTotal": oSettings.fnRecordsDisplay(),
                  "iPage":          Math.ceil( oSettings._iDisplayStart / oSettings._iDisplayLength ),
                  "iTotalPages":    Math.ceil( oSettings.fnRecordsDisplay() / oSettings._iDisplayLength )
              };
          }

          /* Bootstrap style pagination control */
          $.extend( $.fn.dataTableExt.oPagination, {
              "bootstrap": {
                  "fnInit": function( oSettings, nPaging, fnDraw ) {
                      var oLang = oSettings.oLanguage.oPaginate;
                      var fnClickHandler = function ( e ) {
                          e.preventDefault();
                          if ( oSettings.oApi._fnPageChange(oSettings, e.data.action) ) {
                              fnDraw( oSettings );
                          }
                      };

                      $(nPaging).addClass('pagination').append(
                          '<ul>'+
                              '<li class="prev disabled"><a href="#">&larr; '+oLang.sPrevious+'</a></li>'+
                              '<li class="next disabled"><a href="#">'+oLang.sNext+' &rarr; </a></li>'+
                          '</ul>'
                      );
                      var els = $('a', nPaging);
                      $(els[0]).bind( 'click.DT', { action: "previous" }, fnClickHandler );
                      $(els[1]).bind( 'click.DT', { action: "next" }, fnClickHandler );
                  },

                  "fnUpdate": function ( oSettings, fnDraw ) {
                      var iListLength = 5;
                      var oPaging = oSettings.oInstance.fnPagingInfo();
                      var an = oSettings.aanFeatures.p;
                      var i, j, sClass, iStart, iEnd, iHalf=Math.floor(iListLength/2);

                      if ( oPaging.iTotalPages < iListLength) {
                          iStart = 1;
                          iEnd = oPaging.iTotalPages;
                      }
                      else if ( oPaging.iPage <= iHalf ) {
                          iStart = 1;
                          iEnd = iListLength;
                      } else if ( oPaging.iPage >= (oPaging.iTotalPages-iHalf) ) {
                          iStart = oPaging.iTotalPages - iListLength + 1;
                          iEnd = oPaging.iTotalPages;
                      } else {
                          iStart = oPaging.iPage - iHalf + 1;
                          iEnd = iStart + iListLength - 1;
                      }

                      for ( i=0, iLen=an.length ; i<iLen ; i++ ) {
                          // Remove the middle elements
                          $('li:gt(0)', an[i]).filter(':not(:last)').remove();

                          // Add the new list items and their event handlers
                          for ( j=iStart ; j<=iEnd ; j++ ) {
                              sClass = (j==oPaging.iPage+1) ? 'class="active"' : '';
                              $('<li '+sClass+'><a href="#">'+j+'</a></li>')
                                  .insertBefore( $('li:last', an[i])[0] )
                                  .bind('click', function (e) {
                                      e.preventDefault();
                                      oSettings._iDisplayStart = (parseInt($('a', this).text(),10)-1) * oPaging.iLength;
                                      fnDraw( oSettings );
                                  } );
                          }

                          // Add / remove disabled classes from the static elements
                          if ( oPaging.iPage === 0 ) {
                              $('li:first', an[i]).addClass('disabled');
                          } else {
                              $('li:first', an[i]).removeClass('disabled');
                          }

                          if ( oPaging.iPage === oPaging.iTotalPages-1 || oPaging.iTotalPages === 0 ) {
                              $('li:last', an[i]).addClass('disabled');
                          } else {
                              $('li:last', an[i]).removeClass('disabled');
                          }
                      }
                  }
              }
          } );
          
          
          $('#productTable').dataTable({
            "bProcessing": true,
            "bServerSide": true,
            "bPagination": true,
            "bLengthChange": false,
            "iDisplayLength": 6,
            "sPaginationType": "bootstrap",
            "sAjaxSource": ajaxurl + "?action=dashboard_products_table",
            "aoColumns": [
              { "sClass": "left" },
              { "sClass": "center" },
              { "sClass": "right" },
            ],
            "oLanguage": { 
              "sZeroRecords": "<?php 
        _e('No matching Products found', 'cart66');
        ?>
", 
              "sSearch": "<?php 
        _e('Search', 'cart66');
        ?>
:", 
              "sInfo": "<?php 
        _e('Showing', 'cart66');
        ?>
 _START_ <?php 
        _e('to', 'cart66');
        ?>
 _END_ <?php 
        _e('of', 'cart66');
        ?>
 _TOTAL_ <?php 
        _e('entries', 'cart66');
        ?>
", 
              "sInfoEmpty": "<?php 
        _e('Showing 0 to 0 of 0 entries', 'cart66');
        ?>
", 
              "oPaginate": {
                "sNext": "<?php 
        _e('Next', 'cart66');
        ?>
", 
                "sPrevious": "<?php 
        _e('Previous', 'cart66');
        ?>
", 
                "sLast": "<?php 
        _e('Last', 'cart66');
        ?>
", 
                "sFirst": "<?php 
        _e('First', 'cart66');
        ?>
"
              }, 
              "sInfoFiltered": "(<?php 
        _e('filtered from', 'cart66');
        ?>
 _MAX_ <?php 
        _e('total entries', 'cart66');
        ?>
)", 
              "sLengthMenu": "<?php 
        _e('Show', 'cart66');
        ?>
 _MENU_ <?php 
        _e('entries', 'cart66');
        ?>
", 
              "sLoadingRecords": "<?php 
        _e('Loading', 'cart66');
        ?>
...", 
              "sProcessing": "<?php 
        _e('Processing', 'cart66');
        ?>
..." 
            }
          });
        })
      })(jQuery);
    </script> 
    <script type="text/javascript">
      (function($){
        $(document).ready(function() {
          // setting the tabs in the sidebar hide and show, setting the current tab
          $('div.pane').hide();
          $('div.t1').show();
          $('div.loading').hide();
          $('div.cart66Tabbed ul.tabs li.t1 a').addClass('tab-current');
          // SIDEBAR TABS
          $('div.cart66Tabbed ul li a, div.t1 a, div.t1 tr.summaryDetails').click(function(){
            if($(this).hasClass('tab')) {
              var thisClass = this.className.slice(0,2);
              $('div.pane').hide();
              $('div.' + thisClass).fadeIn(300);
              $('div.cart66Tabbed ul.tabs li a').removeClass('tab-current');
              $('div.cart66Tabbed ul.tabs li a.' + thisClass).addClass('tab-current');
            }
          });
        });
      })(jQuery);
    </script><?php 
    }