$xoopsMailer->setBody(sprintf(__('A user has requested more information about the product %s. User message below.', 'shop'), $product->getVar('name')) . "\n---------------\n" . $message . "\n--------------\n" . __('Message sent with MiniShop', 'shop') . "\n" . ShopFunctions::get_url()); $xoopsMailer->setToEmails($xoopsModuleConfig['email']); $xoopsMailer->setFromEmail($email); $xoopsMailer->setFromName($name); $xoopsMailer->setSubject(sprintf(__('Information request about product %s', 'shop'), $product->getVar('name'))); if (!$xoopsMailer->send(true)) { redirect_header($url, 1, __('Message could not be delivered. Please try again.', 'shop')); die; } redirect_header(ShopFunctions::get_url(), 1, __('Your message has been sent successfully!', 'shop')); } else { $xoopsOption['template_main'] = 'shop_contact.html'; include 'header.php'; $tf = new RMTimeFormatter(0, '%d%/%M%/%Y%'); // Product data $xoopsTpl->assign('product', array('name' => $product->getVar('name'), 'description' => $product->getVar('description'), 'price' => sprintf(__('Price: <strong>%s</strong>', 'shop'), sprintf($xoopsModuleConfig['format'], number_format($product->getVar('price'), 2))), 'type' => $product->getVar('type'), 'stock' => $product->getVar('available'), 'image' => $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(), 'images' => $product->get_images())); $categories = array(); ShopFunctions::categos_list($categories); array_walk($categories, 'shop_dashed'); $xoopsTpl->assign('categories_list', $categories); $xoopsTpl->assign('lang_selcat', __('Select category...', 'shop')); $xoopsTpl->assign('xoops_pagetitle', sprintf(__('Requesting information about %s', 'shop'), $product->getVar('name')) . ' » ' . $xoopsModuleConfig['modtitle']); $xoopsTpl->assign('lang_requesting_info', sprintf(__('Request Information for %s', 'shop'), $product->getVar('name'))); $xoopsTpl->assign('lang_yname', __('Your Name:', 'shop')); $xoopsTpl->assign('lang_ymail', __('Your Email:', 'shop')); $xoopsTpl->assign('lang_prod', __('Product:', 'shop')); $xoopsTpl->assign('lang_message', __('Message:', 'shop')); $xoopsTpl->assign('lang_send', __('Send Message', 'shop')); $xoopsTpl->assign('form_action', RMFunctions::current_url()); if ($xoopsUser) { $xoopsTpl->assign('shop_name', $xoopsUser->name());
/** * Form to create or edit products * * @param int Indicates if we are editing an existing product or creating new one */ function shop_new_product($edit = 0) { global $xoopsModuleConfig, $xoopsModule, $xoopsConfig, $xoopsSecurity; if ($edit) { $id = rmc_server_var($_REQUEST, 'id', 0); if ($id <= 0) { redirectMsg('products.php', __('You must provide a valid product ID!', 'shop'), 1); die; } $product = new ShopProduct($id); if ($product->isNew()) { redirectMsg('products.php', __('Specified product does not exists!', 'shop'), 1); die; } } define('RMCSUBLOCATION', 'new_product'); xoops_cp_location('<a href="./">' . $xoopsModule->name() . '</a> » ' . ($edit ? sprintf(__('Editing %s', 'shop'), $product->getVar('name')) : __('Create Product', 'shop'))); xoops_cp_header(); ShopFunctions::include_required_files(); RMTemplate::get()->assign('xoops_pagetitle', $edit ? sprintf(__('Edit "%s"', 'shop'), $product->getVar('name')) : __('Create Product', 'shop')); RMTemplate::get()->add_style('admin.css', 'shop'); RMTemplate::get()->add_local_script('dashboard.js', 'shop'); $form = new RMForm($edit ? __('Edit Product', 'shop') : __('New Product', 'shop'), 'frmProduct', 'products.php'); $form->setExtra('enctype="multipart/form-data"'); $form->addElement(new RMFormText(__('Name', 'shop'), 'name', 50, 200, $edit ? $product->getVar('name') : ''), true); $form->addElement(new RMFormEditor(__('Description', 'shop'), 'description', '100%', '250px', $edit ? $product->getVar("description", 'e') : '', $xoopsModuleConfig['editor']), true); $form->addElement(new RMFormText(__('Price', 'shop'), 'price', 10, 100, $edit ? $product->getVar('price') : '')); $form->addElement(new RMFormText(__('Buy link', 'shop'), 'buy', 50, 255, $edit ? $product->getVar('buy') : 'http://')); $categories = array(); ShopFunctions::categos_list($categories); if ($edit) { $pcats = $product->get_categos(); } else { $pcats = array(); } $cats = new RMFormCheck(''); foreach ($categories as $c) { $cats->addOption(str_repeat("—", $c['indent']) . ' ' . $c['name'], 'cats[]', $c['id_cat'], in_array($c['id_cat'], $pcats) ? 1 : 0); } $form->addElement(new RMFormLabel(__('Categories', 'shop'), '<div class="cats_field">' . $cats->render() . '</div>')); $ele = new RMFormRadio(__('Type', 'shop'), 'type', 1); $ele->addOption(__('Normal', 'shop'), 0, 1); $ele->addOption(__('Digital', 'shop'), 1, 0); $form->addElement($ele); unset($ele); $form->addElement(new RMFormYesNo(__('Available', 'shop'), 'available', 1)); $form->addElement(new RMFormFile(__('Default image', 'shop'), 'image')); if ($edit && $product->getVar('image') != '') { $form->addElement(new RMFormLabel(__('Current Image', 'shop'), '<img src="' . XOOPS_UPLOAD_URL . '/minishop/ths/' . $product->getVar('image') . '" />')); } $metas = $edit ? $product->get_meta() : array(); ob_start(); include RMTemplate::get()->get_template('admin/shop_products_form.php', 'module', 'shop'); $metas_tpl = ob_get_clean(); $form->addElement(new RMFormLabel(__('Custom Fields', 'shop'), $metas_tpl)); $buts = new RMFormButtonGroup(''); $buts->addButton('cancel', __('Cancel', 'shop'), 'button', 'onclick="window.location.href=\'products.php\'"'); $buts->addButton('sbt', $edit ? __('Save Changes', 'shop') : __('Create Product', 'shop'), 'submit'); $form->addElement($buts); $form->addElement(new RMFormHidden('action', $edit ? 'saveedit' : 'save')); if ($edit) { $form->addElement(new RMFormHidden('id', $product->id())); } $form->display(); xoops_cp_footer(); }