示例#1
0
            echo wpinventory_label_class($field);
            ?>
"><?php 
            wpinventory_the_label($field);
            ?>
</th>
				<?php 
        }
    }
    ?>
		</tr>
		</thead>
		<tbody>
		<?php 
    while (wpinventory_have_items()) {
        wpinventory_the_item();
        wpinventory_get_template_part('single-loop-category', 'table');
    }
    ?>
		</tbody>
	</table>
	<?php 
    echo wpinventory_pagination();
} else {
    ?>
	<p class="wpinventory_warning"><?php 
    WPIMCore::_e('No Inventory Items');
    ?>
</p>
<?php 
}
示例#2
0
    /**
     * View for displaying the inventory items in the admin dashboard.
     */
    public static function list_items()
    {
        $inventory_display = wpinventory_get_display_settings('admin');
        $columns = array();
        $name_columns = array('inventory_name', 'inventory_description');
        $ignore_columns = array('inventory_image', 'inventory_images', 'inventory_media');
        foreach ($inventory_display as $item) {
            $class = in_array($item, $name_columns) ? 'name' : 'medium';
            if (!in_array($item, $ignore_columns)) {
                $columns[$item] = array('title' => self::get_label($item), 'class' => $class);
            }
        }
        echo wpinventory_filter_form_admin();
        $args = '';
        $filters = array("inventory_search" => "search", "inventory_sort_by" => "order", "inventory_category_id" => "category_id", "inventory_page" => "page");
        foreach ($filters as $filter => $field) {
            if (self::request($filter)) {
                $args[$field] = self::request($filter);
            }
        }
        $args = self::permission_args($args);
        $loop = new WPIMLoop($args);
        global $wpinventory_item;
        ?>
		<?php 
        if (self::check_permission('add_item', FALSE)) {
            ?>
			<a class="button button-primary"
			   href="<?php 
            echo self::$self_url;
            ?>
&action=add"><?php 
            self::_e('Add Inventory Item');
            ?>
</a>
		<?php 
        }
        ?>
		<table class="grid itemgrid">
			<?php 
        echo self::grid_columns($columns, self::$self_url, 'inventory_number');
        while ($loop->have_items()) {
            $loop->the_item();
            $edit_url = self::check_permission('view_item', $wpinventory_item->inventory_id) ? self::$self_url . '&action=edit&inventory_id=' . $wpinventory_item->inventory_id : '';
            $delete_url = self::check_permission('edit_item', $wpinventory_item->inventory_id) ? self::$self_url . '&action=delete&delete_id=' . $wpinventory_item->inventory_id : '';
            if (!$edit_url) {
                continue;
            }
            ?>
				<tr>
					<?php 
            foreach ($columns as $field => $data) {
                $field = $field == 'category_id' ? 'inventory_category' : $field;
                $url = $edit_url;
                if ($field == 'user_id' || $field == 'inventory_user_id') {
                    $url = get_edit_user_link($wpinventory_item->{$field});
                }
                echo '<td class="' . $field . '"><a href="' . $url . '">' . $loop->get_field($field) . '</a></td>';
            }
            ?>
					<td class="action">
						<?php 
            if ($edit_url) {
                ?>
							<a href="<?php 
                echo $edit_url;
                ?>
"><?php 
                self::_e('edit');
                ?>
</a>
						<?php 
            }
            if ($delete_url) {
                ?>
							<a class="delete" data-name="<?php 
                echo $wpinventory_item->inventory_name;
                ?>
"
							   href="<?php 
                echo $delete_url;
                ?>
"><?php 
                self::_e('delete');
                ?>
</a>
						<?php 
            }
            ?>
						<?php 
            do_action('wpim_admin_action_links', $wpinventory_item->inventory_id);
            ?>
					</td>
				</tr>
			<?php 
        }
        ?>
		</table>

		<?php 
        echo wpinventory_pagination(self::$self_url, $loop->get_pages());
        do_action('wpim_admin_items_listing', $loop->get_query_args());
    }