} $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][] = '£' . $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); $data = $table->toHtml(); } else { $params['TYPE'] = 'info'; if (!$tax_codes) { $params['MESSAGE'] = '<h2>First define some tax codes.</h2>'; } elseif (!$categories) { $params['MESSAGE'] = '<h2>First define some categories.</h2>';
if ($rows > 0) { $items = $tree->getDecendants(true); $c = 0; $data = array(); foreach ($items as $row) { if ($row['depth'] > 0) { if ($row['depth'] > 1) { $r = str_repeat(' ', $row['depth'] - 1); $r .= "• " . $row['item']; $data[$c][] = $r; } else { $data[$c][] = $row['item']; } $data[$c][] = '<a href="/menu/view/id-' . $this->registry->params['id'] . '/action-edit/item-' . $row['item_id'] . '"><img src="/images/24x24/Edit3.png" class="Tips" title="Edit Item" rel="Click to edit the ' . $row['item'] . ' menu" /></a>'; $data[$c][] = '<a href="/menu/view/id-' . $this->registry->params['id'] . '/action-delete/item-' . $row['item_id'] . '" ><img src="/images/24x24/DeleteRed.png" class="Tips" title="Delete item" rel="Click to delete the ' . $row['category'] . ' item" /></a>'; $c++; } } $header = array('Menu Item', '', ''); $table = $this->dataTable($data, $header); } else { $params = array('TYPE' => 'info', 'MESSAGE' => '<h2>There are currently no records.</h2>'); } if ($rows > 0) { $this->content .= '<div id="tableWrap">'; $this->content .= HTML_Element::makeXmlSafe($table->toHtml()); $this->content .= '</div>'; } else { $this->content .= $this->message($params); } }
$menuBar['back'] = $_SESSION['referer_link']; if (!$values['enabled']) { $values['enabled'] = 0; } //check then enter the record. $res = $this->update($values, $ushop->db_name . 'products', array('where' => 'product_id=' . $this->registry->params['id'])); if ($res) { $params['TYPE'] = 'pass'; $params['MESSAGE'] = '<h2>Product was successfully edited.</h2>'; } else { $params['TYPE'] = 'error'; $params['MESSAGE'] = '<h2>Product could not be edited.</h2>'; } // done! } else { $form->setDefaults(array('enabled' => $row->enabled, 'discontinued' => $row->discontinued, 'name' => HTML_Element::makeXmlSafe($row->name), 'sku' => $row->sku, 'category_id' => $row->category_id, 'short_description' => $row->short_description, 'description' => $row->description, 'price' => $row->price, 'price_group_id' => $row->price_group_id, 'postage' => $row->postage, 'weight' => $row->weight, 'author_id' => $row->author_id, 'isbn' => $row->isbn, 'image_status' => $row->image_status, 'quantity' => $row->quantity, 'image' => $row->image)); $tab_array = array('details' => null, 'description' => null, 'price' => null, 'attributes' => null, 'image_upload' => null); foreach ($errors as $value) { $err = $form->getElementError($value); if ($err) { $this->registry->Warning($err); } } $renderer = new UthandoForm(__SITE_PATH . '/templates/' . $this->get('admin_config.site.template')); $renderer->setFormTemplate('form'); $renderer->setHeaderTemplate('header'); $renderer->setElementTemplate('element'); $form->accept($renderer); // output the form $tabs = new HTML_Tabs($tab_array, true); $tabs->addPanels($renderer->toHtml());
FROM uthando_core.ushop_product_categories AS child, uthando_core.ushop_product_categories AS parent, uthando_core.ushop_products AS product WHERE child.lft BETWEEN parent.lft AND parent.rgt AND child.category_id = product.category_id GROUP BY category_id ORDER BY child.lft '); foreach ($rows as $value) { $num_products[$value->category_id] = $value->num_product; } foreach ($tree->getTree("{$start}, {$display}") as $row) { if ($row['depth'] > 0) { $r = str_repeat(str_repeat(' ', 4), $row['depth']); $r .= "• " . HTML_Element::makeXmlSafe($row['category']); $data[$c][] = $r; } else { $data[$c][] = HTML_Element::makeXmlSafe($row['category']); } $data[$c][] = $num_products[$row['category_id']] . ' [show]'; $data[$c][] = '<a href="/ushop/products/action-edit_category/id-' . $row['category_id'] . '" style="text-decoration:none;" ><img src="/templates/' . $this->get('admin_config.site.template') . '/images/24x24/Edit3.png" class="Tips" title="Edit Category" rel="Click to edit this category." /></a>'; $data[$c][] = '<a href="/ushop/products/action-delete_category/id-' . $row['category_id'] . '" ><img src="/templates/' . $this->get('admin_config.site.template') . '/images/24x24/Delete.png" class="Tips" title="Delete Category" rel="Click to delete this category" /></a>'; $c++; } $header = array('Category', 'Products', '', ''); $table = $this->dataTable($data, $header); $data = $table->toHtml(); } else { $params['TYPE'] = 'info'; $params['MESSAGE'] = '<h2>There are currently no records.</h2>'; } if (isset($params)) { $categories = $this->message($params);
// no direct access defined('PARENT_FILE') or die('Restricted access'); if ($this->authorize()) { $display = $ushop->getDisplay('authors'); $num = count($this->getResult('author_id', $ushop->db_name . 'authors')); $start = isset($this->registry->params['astart']) ? $this->registry->params['astart'] : 0; if ($num > $display) { $paginate = new HTML_Paginate('authors', $start, '/ushop/products/astart-{start}/view-attr/authors', $num, $display, false); $this->content .= $paginate->toHTML(); } if ($authors = $this->getResult('author_id, forename, surname', $ushop->db_name . 'authors', null, array('LIMIT' => "{$start}, {$display}"))) { $c = 0; $data = array(); foreach ($authors as $row) { $data[$c][] = HTML_Element::makeXmlSafe($row->forename) . ' ' . HTML_Element::makeXmlSafe($row->surname); $data[$c][] = '<a href="/ushop/products/action-edit_attribute/attr-author/id-' . $row->author_id . '" style="text-decoration:none;" ><img src="/templates/' . $this->get('admin_config.site.template') . '/images/24x24/Edit3.png" class="Tips" title="Edit Author" rel="Click to edit this author." /></a>'; $data[$c][] = '<a href="/ushop/products/action-delete_attribute/attr-author/id-' . $row->author_id . '" ><img src="/templates/' . $this->get('admin_config.site.template') . '/images/24x24/Delete.png" class="Tips" title="Delete Author" rel="Click to delete this author" /></a>'; $c++; } $header = array('Author', '', ''); $table = $this->dataTable($data, $header); $data = $table->toHtml(); } else { $params['TYPE'] = 'info'; $params['MESSAGE'] = '<h2>There are currently no records.</h2>'; $products = $this->message(array('MESSAGE' => '<h2>First define some authors.</h2>', 'TYPE' => 'info')); //$tab_array['products'] = $products; } if (isset($params)) { $authors = $this->message($params);
<?php // no direct access defined('PARENT_FILE') or die('Restricted access'); if ($this->authorize()) { $authors = $this->getResult('author_id, forename, surname', $ushop->db_name . 'authors'); //$author_radio[] = $form->createElement('radio', null, null, 'new', '1'); //$author_radio[] = $form->createElement('radio', null, null, 'Existing', '0'); //$form->addGroup($author_radio, 'author', 'Author:'); if ($authors) { $authors_s = $form->createElement('select', 'author_id', 'Author:'); $authors_opts[0] = 'Select One'; foreach ($authors as $value) { $authors_opts[$value->author_id] = HTML_Element::makeXmlSafe($value->forename, true) . ' ' . HTML_Element::makeXmlSafe($value->surname, true); } $authors_s->loadArray($authors_opts); $form->addElement($authors_s); $errors[] = 'author_id'; } else { $authors = $this->templateParser($tmpl, array('LABEL' => 'Authors:', 'ELEMENT' => 'No authors aviliable'), '{', '}'); $form->addElement('html', $authors); } $form->addRule('author_id', 'Please select an author.', 'required'); $form->addRule('author_id', 'Please select an author.', 'nonzero'); }
public function productDetails($row) { $base_dir = realpath(__SITE_PATH . $this->img_dir); $html = file_get_contents('ushop/html/product.html', true); $params = array('LINK' => '/ushop/view/product/id-' . $row->product_id, 'CART_LINK' => '/ushop/view/cart/action-add/id-' . $row->product_id, 'SEARCH_LINK' => '#'); foreach ($row as $key => $value) { if ($key == ('name' || 'author')) { $value = HTML_Element::makeXmlSafe($value); } if ($key == 'image') { $params[strtoupper($key)] = file_exists($base_dir . '/' . $value) && $value != null ? $this->img_dir . $value : $this->img_dir . 'noimage.png'; } else { $params[strtoupper($key)] = $value; } } if (!$row->image_status) { $html = UShop_Utility::removeSection($html, 'image'); } if ($this->global['catelogue_mode']) { $html = UShop_Utility::removeSection($html, 'add_cart'); } $html = Uthando::templateParser($html, $params, '{', '}'); return $html; }
<?php // no direct access defined('SHOP_PARENT_FILE') or die('Restricted access'); if (is_numeric($this->registry->params['id'])) { $row = $this->getResult($this->ushop->database_selects['product_view'], $this->ushop->db_name . 'products', array($this->ushop->db_name . 'product_categories', $this->ushop->db_name . $this->ushop->database_joins['product_view']), array('WHERE' => 'product_id=' . $this->registry->params['id']), false); $title .= HTML_Element::makeXmlSafe($row->name); $this->content .= '<div id="products">'; $this->content .= $this->ushop->displayCartButtons(); $this->content .= $this->ushop->displayPathway($row->category_id); $this->content .= $this->ushop->productDetails($row); $this->content .= '</div>'; }
$category_id = $tree->insert($ip, $values, $it); if ($category_id) { $params['TYPE'] = 'pass'; $params['MESSAGE'] = '<h2>Menu was successfully added.</h2>'; } else { $params['TYPE'] = 'error'; $params['MESSAGE'] = '<h2>Menu could not be added to the database.</h2>'; } } else { $params['TYPE'] = 'error'; $params['MESSAGE'] = '<h2>Menu could not be added to the database.</h2>'; } } else { $form->setDefaults(array('status_id' => 1, 'item_position' => $this->registry->params['id'], 'insert_type' => 'new child', 'external_link' => 'http://', 'enssl' => 0)); $renderer = new UthandoForm(TEMPLATES . $this->get('admin_config.site.template')); $renderer->setFormTemplate('form'); $renderer->setHeaderTemplate('header'); $renderer->setElementTemplate('element'); $form->accept($renderer); // output the form $this->content .= HTML_Element::makeXmlSafe($renderer->toHtml()); $this->addComponentJS(); } if (isset($params)) { $params['CONTENT'] = $this->makeMessageBar($menuBar, 24); $this->content .= $this->message($params); } } else { Uthando::go('/menu/overview'); } }
public function calculateCartItems() { global $uthando; // reset values $this->cart['subTotal'] = 0; $this->cart['taxTotal'] = 0; $this->cart['postWeight'] = 0; $this->cart['noPostage'] = 0; $this->cart['postTax'] = 0; $this->cart['postCost'] = 0; foreach ($this->cart['items'] as $key => $value) { $row = $uthando->getResult('sku, name, price, weight, tax_rate, image, image_status, vat_inc, postage, quantity', $uthando->ushop->db_name . 'products', array($uthando->ushop->db_name . 'tax_rates'), array('WHERE' => 'product_id=' . $key, 'AND' => array('enabled=1', 'discontinued=0')), false); if ($uthando->ushop->checkout['stock_control']) { if ($value['qty'] > $row->quantity) { $value['qty'] = $row->quantity; $this->updateCart($key, $value['qty']); } if (!$this->cart['items']) { return '<h3>Shopping cart is empty</h3>'; } if ($value['qty'] == 0) { continue; } } $tax_array = $this->calculateVat($row->price, $value['qty'], $row->tax_rate, $row->vat_inc); $tax = $tax_array['tax']; $row->price = $tax_array['price']; $itemTotal = $row->price * $value['qty'] + $tax; $this->cart['subTotal'] += $itemTotal; $this->cart['taxTotal'] += $tax; if ($row->postage == 1) { $itemWeight = $row->weight * $value['qty']; } else { $itemWeight = 0; $this->cart['noPostage'] += $row->price + $tax; } $this->cart['postWeight'] += $itemWeight; if (file_exists(__SITE_PATH . $this->img_dir . $row->image)) { $image = $this->img_dir . $row->image; } else { $image = $this->img_dir . 'noimage.png'; } $items[] = array('PRODUCT_ID' => $key, 'QUANTITY' => $value['qty'], 'SKU' => $row->sku, 'NAME' => HTML_Element::makeXmlSafe($row->name), 'PRICE' => $row->price, 'VAT' => $tax, 'TOTAL' => number_format($itemTotal, 2), 'IMAGE' => $image, 'IMAGE_STATUS' => 'image_' . $row->image_status); } return $items; }