public function output() { $GLOBALS['hide_save_button'] = true; if (isset($_GET['action']) && $_GET['action'] == 'delete') { $this->delete_status(); } if (isset($_GET['action']) && $_GET['action'] == 'edit' && isset($_GET['id']) && !empty($_GET['id'])) { $data = wc_crm_get_status($_GET['id']); ?> <div class="wrap"> <h2><?php _e('Edit Status ', 'wc_customer_relationship_manager'); ?> </h2> <form method="post" action="" enctype="multipart/form-data" id="wc_crm_customer_statuses"> <input type="hidden" value="wc_crm_add_customer_status" name="action"> <input type="hidden" value="<?php echo $_GET['id']; ?> " name="status_id"> <table class="form-table"> <tbody> <tr class="form-field form-required"> <th scope="row"> <label for="status_name"><?php _e('Name', 'wc_customer_relationship_manager'); ?> </label> </th> <td> <input id="status_name" type="text" aria-required="true" size="40" value="<?php echo $data['status_name']; ?> " name="status_name"> </td> </tr> <tr class="form-field"> <th scope="row"> <label for="status_slug"><?php _e('Slug', 'wc_customer_relationship_manager'); ?> </label> </th> <td> <input id="status_slug" type="text" aria-required="true" size="40" value="<?php echo $data['status_slug']; ?> " name="status_slug"> </td> </tr> <tr class="form-field form-required"> <th scope="row"> <label for="status_icon"><?php _e('Icon', 'wc_customer_relationship_manager'); ?> </label> </th> <td> <input id="status_icon" type="text" aria-required="true" size="40" value="<?php echo $data['status_icon']; ?> " name="status_icon"> </td> </tr> <tr class="form-field form-required"> <th scope="row"> <label for="status_colour"><?php _e('Colour', 'wc_customer_relationship_manager'); ?> </label> </th> <td> <input id="status_colour" type="text" aria-required="true" size="40" value="<?php echo $data['status_colour']; ?> " name="status_colour"> </td> </tr> </tbody> </table> <p class="submit"><input type="submit" value="Save Status" class="button button-primary" id="submit" name="submit"></p> <p><a href="<?php echo admin_url('admin.php?page=wc_crm_settings&tab=statuses'); ?> "><?php _e('Back to statuses list', 'wc_customer_relationship_manager'); ?> </a></p> <?php wp_nonce_field('wc-crm-settings'); ?> </form> </div> <?php } else { ?> <div class="wrap nosubsub" id="wc-crm-page"> <h2><?php _e('Customer Status ', 'wc_customer_relationship_manager'); ?> </h2> <div id="col-container"> <div id="col-right"> <div class="col-wrap"> <form method="post" action=""> <?php require_once WC_CRM()->plugin_path() . '/admin/classes/wc_crm_statuses_table.php'; $statuses_table = new WC_CRM_Statuses_Table(); $statuses_table->prepare_items(); $statuses_table->display(); ?> <?php wp_nonce_field('wc-crm-settings'); ?> </form> </div> </div><!-- /col-right --> <div id="col-left"> <div class="col-wrap"> <div class="form-wrap"> <form method="post" action="" enctype="multipart/form-data" id="wc_crm_customer_statuses"> <input type="hidden" value="wc_crm_add_customer_status" name="action"> <div class="form-field form-required"> <label for="status_name"><?php _e('Name', 'wc_customer_relationship_manager'); ?> </label> <input id="status_name" type="text" aria-required="true" size="40" value="" name="status_name"> </div> <div class="form-field"> <label for="status_slug"><?php _e('Slug', 'wc_customer_relationship_manager'); ?> </label> <input id="status_slug" type="text" aria-required="true" size="40" value="" name="status_slug"> </div> <div class="form-field form-required"> <label for="status_icon"><?php _e('Icon', 'wc_customer_relationship_manager'); ?> </label> <input id="status_icon" type="text" aria-required="true" size="40" value="" name="status_icon"> </div> <div class="form-field form-required"> <label for="status_colour"><?php _e('Colour', 'wc_customer_relationship_manager'); ?> </label> <input id="status_colour" type="text" aria-required="true" size="40" value="" name="status_colour"> </div> <p class="submit"><input type="submit" value="Add New Status" class="button button-primary" id="submit" name="submit"></p> <?php wp_nonce_field('wc-crm-settings'); ?> </form> </div> </div> </div><!-- /col-left --> </div><!-- /col-container --> </div> <?php } }
function prepare_items() { $columns = $this->get_columns(); $hidden = array(); self::$data = wc_crm_get_statuses(true, true); $sortable = $this->get_sortable_columns(); $this->_column_headers = array($columns, $hidden, $sortable); usort(self::$data, array(&$this, 'usort_reorder')); $per_page = 10; $current_page = $this->get_pagenum(); $total_items = count(self::$data); if ($_GET['page'] == 'wc_user_grps' || $_GET['page'] == 'wc_crm_settings' && !empty($_GET['tab']) && $_GET['tab'] == 'statuses') { // only ncessary because we have sample data $this->found_data = array_slice(self::$data, ($current_page - 1) * $per_page, $per_page); $this->set_pagination_args(array('total_items' => $total_items, 'per_page' => $per_page)); $this->items = $this->found_data; } else { $this->items = self::$data; } }