Beispiel #1
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();
Beispiel #2
0
/**
 * Presenta un formulario para la creación de una nueva
 * categoría para los artículos
 */
function show_new_form($edit = 1)
{
    global $xoopsModule;
    $id = rmc_server_var($_GET, 'id', 0);
    if ($id <= 0) {
        redirectMsg('categories.php', __('You must specify a valid category', 'shop'), 1);
        die;
    }
    // Cargamos la categoría
    $catego = new ShopCategory($id);
    // Si no existe entonces devolvemos un error
    if ($catego->isNew()) {
        redirectMsg('categories.php', __('Specified category not exists!', 'shop'), 1);
        die;
    }
    ShopFunctions::include_required_files();
    xoops_cp_location('<a href="./">' . $xoopsModule->name() . '</a> &raquo; ' . __('Edit Category', 'shop'));
    xoops_cp_header();
    $cats = array();
    ShopFunctions::categos_list($cats, 0, 0, true, $id);
    $form = new RMForm($edit ? __('Edit Category', 'shop') : __('New Category', 'shop'), 'frmNew', 'categories.php');
    $form->styles('width: 30%;', 'odd');
    $form->addElement(new RMFormText(__('Category name', 'shop'), 'name', 50, 150, $catego->getVar('name')), true);
    $form->addElement(new RMFormText(__('Category slug', 'shop'), 'shortname', '', '150', $catego->getVar('shortname', 'n')));
    $form->addElement(new RMFormTextArea(__('Category description', 'shop'), 'desc', 5, 45, $catego->getVar('description', 'e')));
    $ele = new RMFormSelect(__('Category Parent', 'shop'), 'parent');
    $ele->addOption(0, _SELECT, $catego->getVar('parent') == 0 ? 1 : 0);
    foreach ($cats as $k) {
        $ele->addOption($k['id_cat'], str_repeat("-", $k['indent']) . ' ' . $k['name'], $catego->getVar('parent') == $k['id_cat'] ? 1 : 0);
    }
    $form->addElement($ele);
    $form->addElement(new RMFormHidden('action', 'saveedit'));
    $form->addElement(new RMFormHidden('id', $id));
    $ele = new RMFormButtonGroup('', ' ');
    $ele->addButton('sbt', __('Update Category', 'shop'), 'submit');
    $ele->addButton('cancel', __('Cancel', 'shop'), 'button');
    $ele->setExtra('cancel', "onclick='history.go(-1);'");
    $form->addElement($ele);
    $form->display();
    xoops_cp_footer();
}
Beispiel #3
0
/**
* @desc Formulario de creación/edición de Imágenes
**/
function shop_form_images($edit = 0)
{
    global $xoopsModule, $xoopsModuleConfig;
    $idimg = rmc_server_var($_REQUEST, 'idimg', 0);
    $id = rmc_server_var($_REQUEST, 'id', 0);
    $page = rmc_server_var($_REQUEST, 'page', 0);
    $bname = rmc_server_var($_REQUEST, 'bname', 0);
    $ruta = "action=images&page={$page}&bname={$bname}&id={$id}";
    //Verificamos que el trabajo sea válido
    if ($id <= 0) {
        redirectMsg('products.php', __('You must specify a product ID!', 'shop'), 1);
        die;
    }
    //Verificamos que el trabajo exista
    $product = new ShopProduct($id);
    if ($product->isNew()) {
        redirectMsg('products.php', __('Specified product does not exists!', 'shop'), 1);
        die;
    }
    if ($edit) {
        //Verificamos que la imagen sea válida
        if ($idimg <= 0) {
            redirectMsg('products.php?' . $ruta, __('You must specify an image ID!', 'shop'), 1);
            die;
        }
        //Verificamos que la imagen exista
        $img = new ShopImage($idimg);
        if ($img->isNew()) {
            redirectMsg('products.php?' . $ruta, __('Specified image does not exists!', 'shop'), 1);
            die;
        }
    }
    ShopFunctions::include_required_files();
    RMTemplate::get()->assign('xoops_pagetitle', $product->getVar('name') . ' &raquo; ' . __('Product Images', 'shop'));
    xoops_cp_location('<a href="./">' . $xoopsModule->name() . "</a> &raquo; <a href='products.php?id=" . $product->id() . "'>" . __('Product Images', 'shop') . "</a> &raquo;" . ($edit ? __('Edit Image', 'shop') : __('Add Image', 'shop')));
    xoops_cp_header();
    $form = new RMForm($edit ? __('Edit Image', 'shop') : __('Add Image', 'shop'), 'frmImg', 'products.php');
    $form->setExtra("enctype='multipart/form-data'");
    $form->addElement(new RMFormText(__('Title', 'shop'), 'title', 50, 100, $edit ? $img->getVar('title') : ''), true);
    $form->addElement(new RMFormFile(__('Image file', 'shop'), 'file', 45, $xoopsModuleConfig['size_image'] * 1024), $edit ? false : true);
    if ($edit) {
        $form->addElement(new RMFormLabel(__('Current image file', 'shop'), "<img src='" . XOOPS_UPLOAD_URL . "/minishop/ths/" . $img->getVar('file') . "' />"));
    }
    $form->addElement(new RMFormTextArea(__('Description', 'shop'), 'desc', 4, 50, $edit ? $img->getVar('description', 'e') : ''));
    $form->addElement(new RMFormHidden('action', $edit ? 'saveeditedimage' : 'saveimage'));
    $form->addElement(new RMFormHidden('id', $id));
    $form->addElement(new RMFormHidden('idimg', $img->id()));
    $form->addElement(new RMFormHidden('page', $page));
    $form->addElement(new RMFormHidden('bname', $bname));
    $ele = new RMFormButtonGroup();
    $ele->addButton('sbt', _SUBMIT, 'submit');
    $ele->addButton('cancel', _CANCEL, 'button', 'onclick="window.location=\'products.php?id=' . $product->id() . '\';"');
    $form->addElement($ele);
    $form->display();
    xoops_cp_footer();
}