Beispiel #1
0
    public function displayFormFees()
    {
        global $currentIndex;
        echo '<br /><br />
		<h2>' . $this->l('Fees by carrier, geographical zone, and ranges') . '</h2>
		<form action="' . $currentIndex . '&token=' . $this->token . '" id="fees" name="fees" method="post" class="width2">
			<fieldset>
				<legend><img src="../img/admin/delivery.gif" />' . $this->l('Fees') . '</legend>
				<b>' . $this->l('Carrier:') . ' </b>
				<select name="id_carrier2" onchange="document.fees.submit();">';
        $carriers = Carrier::getCarriers(intval(Configuration::get('PS_LANG_DEFAULT')));
        $id_carrier = Tools::getValue('id_carrier') ? intval(Tools::getValue('id_carrier')) : intval($carriers[0]['id_carrier']);
        $carrierSelected = new Carrier($id_carrier);
        foreach ($carriers as $carrier) {
            echo '<option value="' . intval($carrier['id_carrier']) . '"' . ($carrier['id_carrier'] == $id_carrier ? ' selected="selected"' : '') . '>' . $carrier['name'] . '</option>';
        }
        echo '
				</select><br />
				<table class="table space" cellpadding="0" cellspacing="0">
					<tr>
						<th>' . $this->l('Zone / Range') . '</th>';
        $shipping_method = intval(Configuration::get('PS_SHIPPING_METHOD'));
        $currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
        $rangeObj = $shipping_method ? new RangeWeight() : new RangePrice();
        $rangeTable = $shipping_method ? 'range_weight' : 'range_price';
        $rangeIdentifier = 'id_' . $rangeTable;
        $ranges = $rangeObj->getRanges($id_carrier);
        $suffix = $shipping_method ? Configuration::get('PS_WEIGHT_UNIT') : $currency->sign;
        $delivery = Carrier::getDeliveryPriceByRanges($rangeTable);
        foreach ($delivery as $deliv) {
            $deliveryArray[$deliv['id_zone']][$deliv['id_carrier']][$deliv[$rangeIdentifier]] = $deliv['price'];
        }
        foreach ($ranges as $range) {
            echo '<th style="font-size: 11px;">' . floatval($range['delimiter1']) . $suffix . ' ' . $this->l('to') . ' ' . floatval($range['delimiter2']) . $suffix . '</th>';
        }
        echo '</tr>';
        $zones = Zone::getZones(true);
        if (sizeof($ranges)) {
            foreach ($zones as $zone) {
                if (!$carrierSelected->getZone($zone['id_zone'])) {
                    continue;
                }
                echo '
						<tr>
							<th style="height: 30px;">' . $zone['name'] . '</th>';
                foreach ($ranges as $range) {
                    if (isset($deliveryArray[$zone['id_zone']][$id_carrier][$range[$rangeIdentifier]])) {
                        $price = $deliveryArray[$zone['id_zone']][$id_carrier][$range[$rangeIdentifier]];
                    } else {
                        $price = '0.00';
                    }
                    echo '<td class="center">' . $currency->getSign('left') . '<input type="text" name="fees_' . $zone['id_zone'] . '_' . $range[$rangeIdentifier] . '" value="' . $price . '" style="width: 45px;" />' . $currency->getSign('right') . '</td>';
                }
                echo '
						</tr>';
            }
        }
        echo '
					<tr>
						<td colspan="' . (sizeof($ranges) + 1) . '" class="center" style="border-bottom: none; height: 40px;">
							<input type="hidden" name="submitFees' . $this->table . '" value="1" />
					';
        if (sizeof($ranges)) {
            echo '	<input type="submit" value="' . $this->l('   Save   ') . '" class="button" />';
        } else {
            echo $this->l('No ranges set for this carrier');
        }
        echo '
						</td>
					</tr>';
        echo '
				</table>
				<p>' . $this->l('Prices are tax excluded.') . '</p>
			</fieldset>
			<input type="hidden" name="id_carrier" value="' . $id_carrier . '" />
		</form>';
    }