示例#1
0
/**
* Show the list of existing products with options to mage them
*/
function shop_show_products()
{
    global $xoopsModuleConfig, $xoopsConfig, $xoopsSecurity;
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $page = rmc_server_var($_REQUEST, 'page', 1);
    $limit = 15;
    $bname = rmc_server_var($_REQUEST, 'bname', '');
    //Barra de Navegación
    $sql = "SELECT COUNT(*) FROM " . $db->prefix('shop_products');
    if ($bname != '') {
        $sql .= " WHERE name LIKE '%{$bname}%'";
    }
    list($num) = $db->fetchRow($db->query($sql));
    $tpages = ceil($num / $limit);
    $page = $page > $tpages ? $tpages : $page;
    $start = $num <= 0 ? 0 : ($page - 1) * $limit;
    $nav = new RMPageNav($num, $limit, $page, 5);
    $nav->target_url('products.php?page={PAGE_NUM}&amp;bname=' . $bname);
    $sql = str_replace("COUNT(*)", '*', $sql);
    $sql .= " ORDER BY id_product DESC LIMIT {$start}, {$limit}";
    $result = $db->query($sql);
    $products = array();
    //Container
    $tf = new RMTimeFormatter('', '%M%/%d%/%Y% - %h%:%i%');
    while ($row = $db->fetchArray($result)) {
        $product = new ShopProduct();
        $product->assignVars($row);
        $products[] = array('id' => $product->id(), 'name' => $product->getVar('name'), 'image' => $product->getVar('image') != '' ? XOOPS_UPLOAD_URL . '/minishop/ths/' . $product->getVar('image') : '', 'price' => $product->getVar('price'), 'type' => $product->getVar('type') ? __('Digital', 'shop') : __('Normal', 'shop'), 'stock' => $product->getVar('available'), 'created' => $product->getVar('created') ? $tf->format($product->getVar('created')) : '', 'modified' => $product->getVar('modified') > 0 ? $tf->format($product->getVar('modified')) : '');
    }
    $products = RMEvents::get()->run_event("shop.list.products", $products, $start, $limit);
    RMTemplate::get()->add_style('admin.css', 'shop');
    RMTemplate::get()->add_local_script('admin.js', 'shop');
    RMTemplate::get()->add_local_script('jquery.checkboxes.js', 'rmcommon', 'include');
    RMTemplate::get()->add_head('<script type="text/javascript">
    var shop_select_message = "' . __('Select at least one product in order to run this action!', 'shop') . '";
    var shop_message = "' . __('Do you really wish to delete selected products?', 'shop') . '";
    </script>');
    // Show GUI
    xoops_cp_header();
    include RMTemplate::get()->get_template('admin/shop_products.php', 'module', 'shop');
    xoops_cp_footer();
}
function shop_bk_products_show($options)
{
    include_once XOOPS_ROOT_PATH . '/modules/shop/class/shopproduct.class.php';
    include_once XOOPS_ROOT_PATH . '/modules/shop/class/shopfunctions.php';
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    $limit = $options[2] > 0 ? $options[2] : 5;
    $ord = $options[0] <= 0 ? ' `created` DESC' : 'RAND()';
    $mc = RMUtilities::module_config('shop', 'format');
    if ($options[1] != '') {
        $tp = $db->prefix("shop_products");
        $tc = $db->prefix("shop_categories");
        $tcp = $db->prefix("shop_catprods");
        $sql = "SELECT p.* FROM {$tp} as p, {$tcp} as r WHERE r.cat={$options['1']} AND p.id_product=r.product GROUP BY r.product";
    } else {
        $sql = "SELECT * FROM " . $db->prefix("shop_products");
    }
    $sql .= " ORDER BY {$ord} LIMIT 0,{$limit}";
    $result = $db->query($sql);
    $products = array();
    while ($row = $db->fetchArray($result)) {
        $prod = new ShopProduct();
        $prod->assignVars($row);
        $products[] = array('id' => $prod->id(), 'name' => $prod->getVar('name'), 'link' => $prod->permalink(), 'price' => sprintf($mc, number_format($prod->getVar('price'), 2)), 'type' => $prod->getVar('type') ? __('Digital', 'shop') : 'Product', 'stock' => $prod->getVar('available'), 'image' => $prod->getVar('image'));
    }
    $block['products'] = $products;
    unset($prod, $products, $sql, $result, $row, $ord, $limit, $db);
    $block['show_image'] = $options[3];
    $block['width'] = $options[4];
    $block['height'] = $options[5];
    $block['display'] = $options[6];
    $block['name'] = in_array("name", $options);
    $block['price'] = in_array("price", $options);
    $block['type'] = in_array("type", $options);
    $block['stock'] = in_array("stock", $options);
    $block['lang_stock'] = __('In stock', 'shop');
    $block['lang_nostock'] = __('Out of stock', 'shop');
    // Add styles
    RMTemplate::get()->add_style('blocks.css', 'shop');
    return $block;
}
示例#3
0
<?php

// $Id$
// --------------------------------------------------------------
// MiniShop 3
// Module for catalogs
// Author: Eduardo Cortés <*****@*****.**>
// Email: i.bitcero@gmail.com
// License: GPL 2.0
// --------------------------------------------------------------
$tf = new RMTimeFormatter(0, '%d%/%M%/%Y%');
$var = isset($var) ? $var : 'products';
while ($row = $db->fetchArray($result)) {
    $product = new ShopProduct();
    $product->assignVars($row);
    $sf = new ShopFunctions();
    $xoopsTpl->append($var, array('id' => $product->id(), 'name' => $product->getVar('name'), 'nameid' => $product->getVar('nameid'), 'price' => $product->getVar('price') > 0 ? sprintf(__('Price: <strong>%s</strong>', 'shop'), sprintf($xoopsModuleConfig['format'], number_format($product->getVar('price'), 2))) : '', 'buy' => $sf->get_buy_link($product), 'type' => $product->getVar('type'), 'stock' => $product->getVar('available'), 'image' => SHOP_UPURL . '/ths/' . $product->getVar('image'), 'created' => sprintf(__('Since: <strong>%s</strong>', 'shop'), $tf->format($product->getVar('created'))), 'updated' => $product->getVar('modified') > 0 ? sprintf(__("Updated: <strong>%s</strong>", 'shop'), $tf->format($product->getVar('modified'))) : '', 'link' => $product->permalink(), 'metas' => $product->get_meta()));
}
示例#4
0
// $Id$
// --------------------------------------------------------------
// MiniShop 3
// Module for catalogs
// Author: Eduardo Cortés <*****@*****.**>
// Email: i.bitcero@gmail.com
// License: GPL 2.0
// --------------------------------------------------------------
define('RMCLOCATION', 'dashboard');
include 'header.php';
RMTemplate::get()->add_head('<script type="text/javascript">var xurl="' . XOOPS_URL . '";</script>');
RMTemplate::get()->add_local_script('dashmain.js', 'shop');
RMTemplate::get()->add_style('admin.css', 'shop');
RMTemplate::get()->add_style('dashboard.css', 'shop');
$db = XoopsDatabaseFactory::getDatabaseConnection();
// Products count
$sql = "SELECT COUNT(*) FROM " . $db->prefix("shop_products");
list($prods_count) = $db->fetchRow($db->query($sql));
$sql = "SELECT COUNT(*) FROM " . $db->prefix("shop_categories");
list($cats_count) = $db->fetchRow($db->query($sql));
$sql = "SELECT * FROM " . $db->prefix("shop_products") . " ORDER BY id_product DESC LIMIT 0, 5";
$result = $db->query($sql);
while ($row = $db->fetchArray($result)) {
    $prod = new ShopProduct();
    $prod->assignVars($row);
    $products[] = array('id' => $prod->id(), 'name' => $prod->getVar('name'), 'link' => $prod->permalink(), 'image' => $prod->getVar('image'));
}
ShopFunctions::include_required_files();
xoops_cp_header();
include RMTemplate::get()->get_template('admin/shop_dashboard.php', 'module', 'shop');
xoops_cp_footer();