Example #1
0
<?php

// no direct access
defined('PARENT_FILE') or die('Restricted access');
if ($this->authorize()) {
    if ($this->registry->params['id']) {
        $this->update(array('enabled' => $this->registry->params['enable']), $ushop->db_name . 'products', array('where' => 'product_id=' . $this->registry->params['id']));
    }
    $categories = $this->getResult('category_id', $ushop->db_name . 'product_categories');
    $display = $ushop->getDisplay('product');
    $num = count($this->getResult('product_id', $ushop->db_name . 'products'));
    $start = isset($this->registry->params['pstart']) ? $this->registry->params['pstart'] : 0;
    if ($num > $display) {
        $paginate = new HTML_Paginate('products', $start, '/ushop/products/pstart-{start}/view-products', $num, $display, false);
        $this->content .= $paginate->toHTML();
    }
    if ($products = $this->getResult('product_id, sku, name, price, image, enabled, image_status, category', $ushop->db_name . 'products', array($ushop->db_name . 'product_categories'), array('ORDER BY' => 'sku ASC', 'LIMIT' => "{$start}, {$display}"))) {
        $c = 0;
        $data = array();
        foreach ($products as $row) {
            $data[$c][] = $row->enabled ? '<a href="' . $_SERVER['REQUEST_URI'] . '/enable-0/id-' . $row->product_id . '"  style="text-decoration:none;" ><img src="/images/16x16/IndicatorCircleGreenOn.png" /></a>' : '<a href="' . $_SERVER['REQUEST_URI'] . '/enable-1/id-' . $row->product_id . '"  style="text-decoration:none;" ><img src="/images/16x16/IndicatorCircleRedOff.png" /></a>';
            $data[$c][] = $row->sku;
            $data[$c][] = HTML_Element::makeXmlSafe($row->name);
            $data[$c][] = '&pound;' . $row->price;
            $data[$c][] = $row->category;
            $data[$c][] = '<a href="/ushop/products/action-edit_product/id-' . $row->product_id . '"  style="text-decoration:none;" ><img src="/images/24x24/Edit3.png" class="Tips" title="Edit Product" rel="Click to edit this product." /></a>';
            $data[$c][] = '<a href="/ushop/products/action-delete_product/id-' . $row->product_id . '" ><img src="/images/24x24/Delete.png" class="Tips" title="Delete Product" rel="Click to delete this product" /></a>';
            $c++;
        }
        $header = array('', 'SKU', 'Title', 'Price', 'Category', '', '');
        $table = $this->dataTable($data, $header);
Example #2
0
<?php

// no direct access
defined('PARENT_FILE') or die('Restricted access');
if ($this->authorize()) {
    $customBar = array('back' => '/ushop/overview', 'new_customer' => '');
    $menuBar = array_merge($customBar, $menuBar);
    unset($menuBar['customers']);
    $this->addContent($this->makeToolbar($menuBar, 24));
    $display = $ushop->getDisplay('customers');
    $num = count($this->getResult('user_id', $ushop->db_name . 'user_info'));
    $start = isset($this->registry->params['cstart']) ? $this->registry->params['cstart'] : 0;
    if ($num > $display) {
        $paginate = new HTML_Paginate('customers', $start, '/ushop/customers/cstart-{start}#customers', $num, $display, false);
        $content = $paginate->toHTML();
    }
    $customers = $this->getResult("user_id, CONCAT(prefix, ' ', first_name, ' ', last_name) as name", $ushop->db_name . 'user_info', array($this->registry->user . 'users', $ushop->db_name . 'user_prefix'), array('ORDER BY' => 'last_name, first_name', 'LIMIT' => "{$start}, {$display}"));
    if ($customers) {
        $c = 0;
        $data = array();
        foreach ($customers as $row) {
            $orders = $this->getRow('
				SELECT COUNT(order_id) as num_orders
				FROM ' . $ushop->db_name . 'orders
				WHERE user_id = :user_id
			', array(':user_id' => $row->user_id));
            $data[$c][] = $row->name;
            $data[$c][] = $orders->num_orders;
            $c++;
        }
        $header = array('Customer', 'Orders');