Example #1
0
    public function displayProducts()
    {
        global $currentIndex, $cookie;
        if (isset($this->_list['obj'])) {
            $nbProducts = sizeof($this->_list['obj']);
            echo '<h3>' . $this->_list['message'] . ' ' . $nbProducts . ' ' . $this->l('found') . '</h3>';
            if (!$nbProducts) {
                return;
            }
            $this->fieldsDisplay = array('ID' => array('title' => $this->l('ID')), 'manufacturer' => array('title' => $this->l('Manufacturer')), 'reference' => array('title' => $this->l('Reference')), 'name' => array('title' => $this->l('Name')), 'price' => array('title' => $this->l('Price')), 'tax' => array('title' => $this->l('Tax')), 'stock' => array('title' => $this->l('Stock')), 'weight' => array('title' => $this->l('Weight')), 'status' => array('title' => $this->l('Status')), 'action' => array('title' => $this->l('Actions')));
            $currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
            echo '
			<table class="table" cellpadding="0" cellspacing="0">
				<tr>';
            foreach ($this->fieldsDisplay as $field) {
                echo '<th' . (isset($field['width']) ? 'style="width: ' . $field['width'] . '"' : '') . '>' . $field['title'] . '</th>';
            }
            echo '
				</tr>';
            foreach ($this->_list['obj'] as $k => $prod) {
                $product = new Product(intval($prod['id_product']));
                $product->name = $product->name[intval($cookie->id_lang)];
                $tax = new Tax(intval($product->id_tax));
                echo '
				<tr>
					<td>' . $product->id . '</td>
					<td align="center">' . ($product->manufacturer_name != NULL ? stripslashes($product->manufacturer_name) : '--') . '</td>
					<td>' . $product->reference . '</td>
					<td><a href="index.php?tab=AdminCatalog&id_product=' . $product->id . '&addproduct&token=' . Tools::getAdminToken('AdminCatalog' . intval(Tab::getIdFromClassName('AdminCatalog')) . intval($cookie->id_employee)) . '">' . stripslashes($product->name) . '</a></td>
					<td>' . Tools::displayPrice($product->getPriceLC(), $currency) . '</td>
					<td>' . stripslashes($tax->name[intval($cookie->id_lang)]) . '</td>
					<td align="center">' . $product->quantity . '</td>
					<td align="center">' . $product->weight . ' ' . Configuration::get('PS_WEIGHT_UNIT') . '</td>
					<td align="center"><a href="index.php?tab=AdminCatalog&id_product=' . $product->id . '&status&token=' . Tools::getAdminToken('AdminCatalog' . intval(Tab::getIdFromClassName('AdminCatalog')) . intval($cookie->id_employee)) . '"><img src="../img/admin/' . ($product->active ? 'enabled.gif' : 'disabled.gif') . '" alt="" /></a></td>
					<td>
						<a href="index.php?tab=AdminCatalog&id_product=' . $product->id . '&addproduct&token=' . Tools::getAdminToken('AdminCatalog' . intval(Tab::getIdFromClassName('AdminCatalog')) . intval($cookie->id_employee)) . '">
						<img src="../img/admin/edit.gif" alt="' . $this->l('Modify this product') . '" /></a>&nbsp;
						<a href="index.php?tab=AdminCatalog&id_product=' . $product->id . '&deleteproduct&token=' . Tools::getAdminToken('AdminCatalog' . intval(Tab::getIdFromClassName('AdminCatalog')) . intval($cookie->id_employee)) . '" onclick="return confirm(\'' . addslashes($this->l('Do you want to delete') . ' ' . $product->name) . ' ?\');">
						<img src="../img/admin/delete.gif" alt="' . $this->l('Delete this product') . '" /></a>
					</td>
				</tr>';
            }
            echo '</table><br /><br />';
        }
    }