Beispiel #1
0
/**
 * Get contact gorup dropdown
 *
 * @since 1.0
 *
 * @param  array  $label
 *
 * @return array
 */
function erp_crm_get_contact_group_dropdown($label = [])
{
    $groups = erp_crm_get_contact_groups(['number' => '-1']);
    $list = [];
    $unsubscribe_text = '';
    foreach ($groups as $key => $group) {
        $list[$group->id] = '<span class="group-name">' . $group->name . '</span>';
        // $list[$group->id] = $group->name;
    }
    if ($label) {
        $list = $label + $list;
    }
    return $list;
}
 /**
  * Prepare the class items
  *
  * @return void
  */
 function prepare_items()
 {
     $columns = $this->get_columns();
     $hidden = [];
     $sortable = $this->get_sortable_columns();
     $this->_column_headers = [$columns, $hidden, $sortable];
     $per_page = 20;
     $current_page = $this->get_pagenum();
     $offset = ($current_page - 1) * $per_page;
     $this->page_status = isset($_GET['status']) ? sanitize_text_field($_GET['status']) : 'all';
     // only ncessary because we have sample data
     $args = ['offset' => $offset, 'number' => $per_page];
     // Filter for order by
     if (isset($_REQUEST['orderby']) && !empty($_REQUEST['orderby'])) {
         $args['orderby'] = $_REQUEST['orderby'];
     }
     // Filter for order
     if (isset($_REQUEST['order']) && !empty($_REQUEST['order'])) {
         $args['order'] = $_REQUEST['order'];
     }
     // Prepare all item after all filtering
     $this->items = erp_crm_get_contact_groups($args);
     // Render total customer according to above filter
     $args['count'] = true;
     $total_items = erp_crm_get_contact_groups($args);
     // Set pagination according to filter
     $this->set_pagination_args(['total_items' => $total_items, 'per_page' => $per_page]);
 }