/**
   * Function for displaying WPI Data Table rows
   *
   * Ported from WP-CRM
   *
   * @since 3.0
   *
   */
  function wpi_list_table() {
    global $wpi_settings;

    include WPI_Path . '/core/ui/class_wpi_object_list_table.php';

    //** Get the paramters we care about */
    $sEcho = $_REQUEST['sEcho'];
    $per_page = $_REQUEST['iDisplayLength'];
    $iDisplayStart = $_REQUEST['iDisplayStart'];
    $iColumns = $_REQUEST['iColumns'];
    $sColumns = $_REQUEST['sColumns'];
    $order_by = $_REQUEST['iSortCol_0'];
    $sort_dir = $_REQUEST['sSortDir_0'];
    $current_screen = $wpi_settings['pages']['main'];

    //** Parse the serialized filters array */
    parse_str($_REQUEST['wpi_filter_vars'], $wpi_filter_vars);
    $wpi_search = $wpi_filter_vars['wpi_search'];

    $sColumns = explode("," , $sColumns);

    //* Init table object */
    $wp_list_table = new WPI_Object_List_Table(array(
      "ajax" => true,
      "per_page" => $per_page,
      "iDisplayStart" => $iDisplayStart,
      "iColumns" => $iColumns,
      "current_screen" => $current_screen
    ));

    if ( in_array( $sColumns[$order_by], $wp_list_table->get_sortable_columns() ) ) {
      $wpi_search['sorting'] = array(
        'order_by' => $sColumns[$order_by],
        'sort_dir' => $sort_dir
      );
    }

    $wp_list_table->prepare_items($wpi_search);

    if ( $wp_list_table->has_items() ) {
      foreach ( $wp_list_table->items as $count => $item ) {
        $data[] = $wp_list_table->single_row( $item );
      }
    } else {
      $data[] = $wp_list_table->no_items();
    }

    return json_encode(array(
      'sEcho' => $sEcho,
      'iTotalRecords' => count($wp_list_table->all_items),
      // @TODO: Why iTotalDisplayRecords has $wp_list_table->all_items value ? Maxim Peshkov
      'iTotalDisplayRecords' =>count($wp_list_table->all_items),
      'aaData' => $data
    ));
  }
Example #2
0
<?php

/*
Page Hook / Hook Suffix: invoice_page_wpi_spc
Pre-header Action Hook: load-invoice_page_wpi_spc 
WPI Page Var: $wpi_settings['pages']['spc']
*/
include 'class-wpi-object-list-table.php';
$post_type = 'wpi_object';
$post_type_object = get_post_type_object($post_type);
if (!current_user_can($post_type_object->cap->edit_posts)) {
    wp_die(__('Cheatin&#8217; uh?'));
}
$wp_list_table = new WPI_Object_List_Table();
$pagenum = $wp_list_table->get_pagenum();
$parent_file = "admin.php?page=wpi_main";
$submenu_file = "admin.php?page=wpi_main";
$post_new_file = "admin.php?page=wpi_page_manage_invoice";
$doaction = $wp_list_table->current_action();
$wp_list_table->prepare_items();
$total_pages = $wp_list_table->get_pagination_arg('total_pages');
if ($pagenum > $total_pages && $total_pages > 0) {
    wp_redirect(add_query_arg('paged', $total_pages));
    exit;
}
$title = $post_type_object->labels->name;
?>
 <div class="wrap">
    <?php 
screen_icon();
?>
<?php

  if(isset($_REQUEST['message']) && $_REQUEST['message'] == 'user_deleted') {
    //WP_wpi_F::add_message(__('User has been deleted.'));
  } 
  
  include WPI_Path . '/core/ui/class_wpi_object_list_table.php';

  $wp_list_table = new WPI_Object_List_Table("per_page=25");
 
  $wp_list_table->prepare_items();

  $wp_list_table->data_tables_script();
  
?>


<div class="wp_wpi_overview_wrapper wrap">
    <?php do_action( 'wpi_before_overview' ); ?>
    <?php screen_icon(); ?>
    <h2><?php _e('Overview', WPI); ?> <a href="<?php echo admin_url('admin.php?page=wpi_page_manage_invoice'); ?>" class="button add-new-h2"><?php _e('Add New', WPI); ?></a></h2>
    <?php WPI_Functions::print_messages(); ?>
    
    <div id="poststuff" class="<?php echo $current_screen->id; ?>_table metabox-holder has-right-sidebar">
    <form id="<?php echo $wp_list_table->table_scope; ?>-filter" action="#" method="POST">

    <div class="wp_wpi_sidebar inner-sidebar">
      <div class="meta-box-sortables ui-sortable">
        <?php do_meta_boxes($current_screen->id, 'normal', $wp_list_table); ?>
      </div>
    </div>