function displayFormQuantityDiscount($obj, $languages, $defaultLanguage)
    {
        global $cookie, $currentIndex;
        if ($obj->id) {
            $quantityDiscounts = QuantityDiscount::getQuantityDiscounts($obj->id, false);
            $defaultCurrency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
            echo '
			<table cellpadding="5">
				<tr>
					<td colspan="2"><b>' . $this->l('Add quantity discount to this product') . '</b></td>
				</tr>
			</table>
			<hr style="width:730px;"><br />
			<table cellpadding="5" style="width:100%">
				<tr>
					<td style="width:150" valign="top">' . $this->l('Product quantity:') . '</td>
					<td>
						<input type="text" name="quantity_discount" size="10" />
						<p style="padding:0px; margin:0px 0px 10px 0px;">' . $this->l('Minimum product quantity for discount') . '</p>
					</td>
				</tr>
				<tr>
					<td style="width:150" valign="top">' . $this->l('Discount value:') . '</td>
					<td>
						<input type="text" name="value_discount" size="10" />
						<p style="padding:0px; margin:0px 0px 10px 0px;">' . $this->l('The discount value (% or amount)') . '</p>
					</td>
				</tr>
				<tr>
					<td style="width:150" valign="top">' . $this->l('Discount type:') . '</td>
					<td>
						<select name="id_discount_type">
							<option value="1">' . $this->l('By %') . '</option>
							<option value="2">' . $this->l('By amount') . '</option>
						</select>
						<p style="padding:0px; margin:0px 0px 10px 0px;">' . $this->l('Will be applied on final product price') . '</p>
					</td>
				</tr>
				<tr>
					<td colspan="2" style="text-align:center;">
						<input type="submit" name="submitQuantityDiscount" id="submitQuantityDiscount" value="' . $this->l('Add quantity discount') . '" class="button" onclick="this.form.action += \'&addproduct&tabs=5\';" />
					</td>
				</tr>
				<tr><td colspan="2"><hr style="width:730px;"></td></tr>
				<tr>
					<td colspan="2"  style="text-align:center;">
						<table border="0" cellpadding="0" cellspacing="0" class="table" style="width:270px; margin:auto;">
							<tr>
								<th style="width:20px">' . $this->l('ID') . '</td>
								<th style="width:100px">' . $this->l('# products') . '</td>
								<th style="width:100px">' . $this->l('Discount') . '</td>
								<th style="width:50px">' . $this->l('Action') . '</td>
							</tr>';
            // Listing
            $irow = 0;
            if (is_array($quantityDiscounts) and sizeof($quantityDiscounts)) {
                foreach ($quantityDiscounts as $qD) {
                    echo '
							<tr ' . ($irow++ % 2 ? ' class="alt_row"' : '') . '>
								<td style="width:25px" style="text-align:center;">' . $qD['id_discount_quantity'] . '</td>
								<td style="width:100px">&nbsp;' . $qD['quantity'] . '</td>
								<td style="width:100px">' . ($qD['id_discount_type'] == 1 ? $qD['value'] . '%' : Tools::displayPrice($qD['value'], $defaultCurrency)) . '</td>
								<td style="width:50px" style="text-align:center;">
									<a href="index.php?tab=AdminCatalog&id_category=' . Tools::getValue('id_category') . '&id_product=' . Tools::getValue('id_product') . '&token=' . Tools::getValue('token') . '&deleteQuantityDiscount&id_quantity_discount=' . $qD['id_discount_quantity'] . '&token=' . Tools::getAdminToken('AdminCatalog' . intval(Tab::getIdFromClassName('AdminCatalog')) . intval($cookie->id_employee)) . '" onclick="return confirm(\'' . $this->l('Are you sure?', __CLASS__, true, false) . '\');">
										<img src="../img/admin/delete.gif" alt="' . $this->l('Delete this discount') . '" />
									</a>
								</td>
							</tr>';
                }
            } else {
                echo '
							<tr><td colspan="4" style="text-align:center;">' . $this->l('No quantity discount defined') . '</td></tr>';
            }
            echo '
						</table>
					</td>
				</tr>
			</table>';
        } else {
            echo '<b>' . $this->l('You must save this product before adding quantity discounts') . '.</b>';
        }
    }
Exemple #2
0
         }
     }
 }
 if (!$category) {
     $category = new Category($product->id_category_default, intval($cookie->id_lang));
 }
 if (isset($category) and Validate::isLoadedObject($category)) {
     $smarty->assign(array('category' => $category, 'subCategories' => $category->getSubCategories(intval($cookie->id_lang), true), 'id_category_current' => intval($category->id), 'id_category_parent' => intval($category->id_parent), 'return_category_name' => Tools::safeOutput(Category::hideCategoryPosition($category->name))));
 }
 $smarty->assign(array('return_link' => (isset($category->id) and $category->id) ? Tools::safeOutput($link->getCategoryLink($category)) : 'javascript: history.back();', 'path' => (isset($category->id) and $category->id) ? Tools::getFullPath(intval($category->id), $product->name) : Tools::getFullPath(intval($product->id_category_default), $product->name)));
 $lang = Configuration::get('PS_LANG_DEFAULT');
 if (Pack::isPack(intval($product->id), intval($lang)) and !Pack::isInStock(intval($product->id), intval($lang))) {
     $product->quantity = 0;
 }
 /* /Quantity discount management */
 $smarty->assign(array('quantity_discounts' => QuantityDiscount::getQuantityDiscounts(intval($product->id), $product->getPriceWithoutReduct()), 'product' => $product, 'homeSize' => Image::getSize('home'), 'jqZoomEnabled' => $jqZoomEnabled, 'product_manufacturer' => new Manufacturer(intval($product->id_manufacturer)), 'token' => Tools::getToken(false), 'productPriceWithoutEcoTax' => floatval($productPriceWithoutEcoTax), 'features' => $features, 'attachments' => $attachments, 'allow_oosp' => $product->isAvailableWhenOutOfStock(intval($product->out_of_stock)), 'last_qties' => intval($configs['PS_LAST_QTIES']), 'group_reduction' => (100 - Group::getReduction(intval($cookie->id_customer))) / 100, 'col_img_dir' => _PS_COL_IMG_DIR_, 'HOOK_EXTRA_LEFT' => Module::hookExec('extraLeft'), 'HOOK_EXTRA_RIGHT' => Module::hookExec('extraRight'), 'HOOK_PRODUCT_OOS' => Hook::productOutOfStock($product), 'HOOK_PRODUCT_FOOTER' => Hook::productFooter($product, $category), 'HOOK_PRODUCT_ACTIONS' => Module::hookExec('productActions'), 'HOOK_PRODUCT_TAB' => Module::hookExec('productTab'), 'HOOK_PRODUCT_TAB_CONTENT' => Module::hookExec('productTabContent')));
 $images = $product->getImages(intval($cookie->id_lang));
 $productImages = array();
 foreach ($images as $k => $image) {
     if ($image['cover']) {
         $smarty->assign('mainImage', $images[0]);
         $cover = $image;
         $cover['id_image'] = intval($product->id) . '-' . $cover['id_image'];
         $cover['id_image_only'] = intval($image['id_image']);
     }
     $productImages[intval($image['id_image'])] = $image;
 }
 if (!isset($cover)) {
     $cover = array('id_image' => Language::getIsoById($cookie->id_lang) . '-default', 'legend' => 'No picture', 'title' => 'No picture');
 }
 $size = Image::getSize('large');